Skip to content

git_ui: Always use latest commit message on amend#44553

Merged
smitbarmase merged 3 commits intomainfrom
41567-amend-improvements
Dec 12, 2025
Merged

git_ui: Always use latest commit message on amend#44553
smitbarmase merged 3 commits intomainfrom
41567-amend-improvements

Conversation

@dinocosta
Copy link
Member

@dinocosta dinocosta commented Dec 10, 2025

Update the behavior of git::Amend to ensure that the latest head commit message, if available, is always loaded into the commit message editor, regardless of its state. The previous text, if any, is now also restored after the amend is finished.

  • Update FakeGitRepository.show to include a message in the returned CommitDetails so we can assert that this specific commit message is set in the commit message editor.
  • Add default implementation for FakeGitRepository.commit and FakeGitRepository.run_hook to ensure that tests are able to run and don't panic on unimplemented!()
  • Refactor GitPanel.load_last_commit_message_if_empty to GitPanel.load_last_commit_message, ensuring that the head commit message is always loaded, regardless of whether the commit message editor is empty.
  • Update GitPanel.commit_changes to ensure that the pending amend state is only updated if the editor managed to actually commit the changes. This also ensures that we don't restore the commit message editor's contents when amending a commit, before the amend is actually processed.
  • Update CommitModal.amend, removing the call to GitPanel.set_amend_pending as that is now handled by the background task created in GitPanel.commit_changes.
  • Split the commit and amend methods from the event handlers so that the methods can be called directly, as is now being done by CommitModal.on_commit and CommitModal.on_amend.

Release Notes:

  • Updated the ‎git: amend command to always load the latest head commit message, and to restore any previously entered text in the commit message editor after the amend completes

- Update `FakeGitRepository.show` to include a message in the returned
  `CommitDetails` so we can assert that this specific commit message is
  set in the commit message editor.
- Add default implementation for `FakeGitRepository.commit` and
  `FakeGitRepository.run_hook` to ensure that tests are able to run and
  don't panic on `unimplemented!()`
- Refactor `GitPanel.load_last_commit_message_if_empty` to
  `GitPanel.load_last_commit_message`, ensuring that the head commit
  message is always loaded, regardless of whether the commit message
  editor is empty.

A new test has also been introduced for these changes but, on actual
testing I've noticed that the editor is still clearing after amending
the commit. I believe this has to do witht the `GitPanel.commit_changes`
implementation, seeing as there's a background task that is spawned
which, after successful completion, clears the commit message editor.
- Update `GitPanel.commit_changes` to ensure that the pending amend
  state is only updated if the editor managed to actually commit the
  changes. This also ensures that we don't restore the commit message
  editor's contents when amending a commit, before the amend is actually
  processed.
- Update `CommitModal.amend`, removing the call to
  `GitPanel.set_amend_pending` as that is now handled by the background
  task created in `GitPanel.commit_changes`.
Split the `commit` and `amend` methods from the event handlers so that
the methods can be called directly, as is now being done by
`CommitModal.on_commit` and `CommitModal.on_amend`.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 10, 2025
@dinocosta dinocosta marked this pull request as ready for review December 10, 2025 15:28
@dinocosta dinocosta self-assigned this Dec 10, 2025
@smitbarmase smitbarmase merged commit 23d18fd into main Dec 12, 2025
25 checks passed
@smitbarmase smitbarmase deleted the 41567-amend-improvements branch December 12, 2025 06:46
nrbnlulu pushed a commit to nrbnlulu/zed that referenced this pull request Dec 14, 2025
Update the behavior of `git::Amend` to ensure that the latest head
commit message, if available, is always loaded into the commit message
editor, regardless of its state. The previous text, if any, is now also
restored after the amend is finished.

- Update `FakeGitRepository.show` to include a message in the returned
`CommitDetails` so we can assert that this specific commit message is
set in the commit message editor.
- Add default implementation for `FakeGitRepository.commit` and
`FakeGitRepository.run_hook` to ensure that tests are able to run and
don't panic on `unimplemented!()`
- Refactor `GitPanel.load_last_commit_message_if_empty` to
`GitPanel.load_last_commit_message`, ensuring that the head commit
message is always loaded, regardless of whether the commit message
editor is empty.
- Update `GitPanel.commit_changes` to ensure that the pending amend
state is only updated if the editor managed to actually commit the
changes. This also ensures that we don't restore the commit message
editor's contents when amending a commit, before the amend is actually
processed.
- Update `CommitModal.amend`, removing the call to
`GitPanel.set_amend_pending` as that is now handled by the background
task created in `GitPanel.commit_changes`.
- Split the `commit` and `amend` methods from the event handlers so that
the methods can be called directly, as is now being done by
`CommitModal.on_commit` and `CommitModal.on_amend`.

Release Notes:

- Updated the ‎`git: amend` command to always load the latest head
commit message, and to restore any previously entered text in the commit
message editor after the amend completes
CherryWorm pushed a commit to CherryWorm/zed that referenced this pull request Dec 16, 2025
Update the behavior of `git::Amend` to ensure that the latest head
commit message, if available, is always loaded into the commit message
editor, regardless of its state. The previous text, if any, is now also
restored after the amend is finished.

- Update `FakeGitRepository.show` to include a message in the returned
`CommitDetails` so we can assert that this specific commit message is
set in the commit message editor.
- Add default implementation for `FakeGitRepository.commit` and
`FakeGitRepository.run_hook` to ensure that tests are able to run and
don't panic on `unimplemented!()`
- Refactor `GitPanel.load_last_commit_message_if_empty` to
`GitPanel.load_last_commit_message`, ensuring that the head commit
message is always loaded, regardless of whether the commit message
editor is empty.
- Update `GitPanel.commit_changes` to ensure that the pending amend
state is only updated if the editor managed to actually commit the
changes. This also ensures that we don't restore the commit message
editor's contents when amending a commit, before the amend is actually
processed.
- Update `CommitModal.amend`, removing the call to
`GitPanel.set_amend_pending` as that is now handled by the background
task created in `GitPanel.commit_changes`.
- Split the `commit` and `amend` methods from the event handlers so that
the methods can be called directly, as is now being done by
`CommitModal.on_commit` and `CommitModal.on_amend`.

Release Notes:

- Updated the ‎`git: amend` command to always load the latest head
commit message, and to restore any previously entered text in the commit
message editor after the amend completes
someone13574 pushed a commit to someone13574/zed that referenced this pull request Dec 16, 2025
Update the behavior of `git::Amend` to ensure that the latest head
commit message, if available, is always loaded into the commit message
editor, regardless of its state. The previous text, if any, is now also
restored after the amend is finished.

- Update `FakeGitRepository.show` to include a message in the returned
`CommitDetails` so we can assert that this specific commit message is
set in the commit message editor.
- Add default implementation for `FakeGitRepository.commit` and
`FakeGitRepository.run_hook` to ensure that tests are able to run and
don't panic on `unimplemented!()`
- Refactor `GitPanel.load_last_commit_message_if_empty` to
`GitPanel.load_last_commit_message`, ensuring that the head commit
message is always loaded, regardless of whether the commit message
editor is empty.
- Update `GitPanel.commit_changes` to ensure that the pending amend
state is only updated if the editor managed to actually commit the
changes. This also ensures that we don't restore the commit message
editor's contents when amending a commit, before the amend is actually
processed.
- Update `CommitModal.amend`, removing the call to
`GitPanel.set_amend_pending` as that is now handled by the background
task created in `GitPanel.commit_changes`.
- Split the `commit` and `amend` methods from the event handlers so that
the methods can be called directly, as is now being done by
`CommitModal.on_commit` and `CommitModal.on_amend`.

Release Notes:

- Updated the ‎`git: amend` command to always load the latest head
commit message, and to restore any previously entered text in the commit
message editor after the amend completes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants