# git_ui: Always use latest commit message on amend \(\#44553\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/23d18fde8c88256884f171f031ebfb201711e00e)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 23d18fde8c88256884f171f031ebfb201711e00e

Requested commit: 23d18fde8c88256884f171f031ebfb201711e00e

Commit: 23d18fde8c88256884f171f031ebfb201711e00e

Tree: 5dd9e594114bf80338800cdf04b2228e69cf0476

Author: Dino

Committer: GitHub

## Message

```
git_ui: Always use latest commit message on amend (#44553)

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
```

## Parents

- [332c0d03d12807b650e15b84634808e092e47569](https://git.cafe/gitcafe/zed/commit/332c0d03d12807b650e15b84634808e092e47569?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/23d18fde8c88256884f171f031ebfb201711e00e?format=markdown)
