Use a waiting status for rewording a non-head commit (#4343)

- **PR Description**

Rewording a commit at the beginning of a long branch can take very long;
without this change, the commit message panel would stay visible with a
blinking cursor during that time, which is very confusing.

This has the slight downside that it will say "Rebasing" in the lower
right corner until the operation is done; but we already have this problem
when doing custom patch operations, or dropping changes from a commit, so it's not
new, and we can think about how to fix all these another time.

- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [ ] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
This commit is contained in:
Stefan Haller 2025-03-06 08:18:34 +01:00 committed by GitHub
commit 6a15a5915b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 11 deletions

View file

@ -409,21 +409,19 @@ func (self *LocalCommitsController) switchFromCommitMessagePanelToEditor(filepat
}
func (self *LocalCommitsController) handleReword(summary string, description string) error {
var err error
if models.IsHeadCommit(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx()) {
// we've selected the top commit so no rebase is required
err = self.c.Helpers().GPG.WithGpgHandling(self.c.Git().Commit.RewordLastCommit(summary, description),
self.c.Tr.CommittingStatus, nil)
} else {
err = self.c.Git().Rebase.RewordCommit(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), summary, description)
return self.c.Helpers().GPG.WithGpgHandling(self.c.Git().Commit.RewordLastCommit(summary, description),
self.c.Tr.RewordingStatus, nil)
}
if err != nil {
return err
}
self.c.Helpers().Commits.OnCommitSuccess()
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
return self.c.WithWaitingStatus(self.c.Tr.RewordingStatus, func(gocui.Task) error {
err := self.c.Git().Rebase.RewordCommit(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), summary, description)
if err != nil {
return err
}
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
})
}
func (self *LocalCommitsController) doRewordEditor() error {

View file

@ -384,6 +384,7 @@ type TranslationSet struct {
RedoingStatus string
CheckingOutStatus string
CommittingStatus string
RewordingStatus string
RevertingStatus string
CreatingFixupCommitStatus string
CommitFiles string
@ -1425,6 +1426,7 @@ func EnglishTranslationSet() *TranslationSet {
RedoingStatus: "Redoing",
CheckingOutStatus: "Checking out",
CommittingStatus: "Committing",
RewordingStatus: "Rewording",
RevertingStatus: "Reverting",
CreatingFixupCommitStatus: "Creating fixup commit",
CommitFiles: "Commit files",