Skip to content

Commit 6a15a59

Browse files
authored
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
2 parents ddc14ef + e6d6ed4 commit 6a15a59

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pkg/gui/controllers/local_commits_controller.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -409,21 +409,19 @@ func (self *LocalCommitsController) switchFromCommitMessagePanelToEditor(filepat
409409
}
410410

411411
func (self *LocalCommitsController) handleReword(summary string, description string) error {
412-
var err error
413-
414412
if models.IsHeadCommit(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx()) {
415413
// we've selected the top commit so no rebase is required
416-
err = self.c.Helpers().GPG.WithGpgHandling(self.c.Git().Commit.RewordLastCommit(summary, description),
417-
self.c.Tr.CommittingStatus, nil)
418-
} else {
419-
err = self.c.Git().Rebase.RewordCommit(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), summary, description)
414+
return self.c.Helpers().GPG.WithGpgHandling(self.c.Git().Commit.RewordLastCommit(summary, description),
415+
self.c.Tr.RewordingStatus, nil)
420416
}
421417

422-
if err != nil {
423-
return err
424-
}
425-
self.c.Helpers().Commits.OnCommitSuccess()
426-
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
418+
return self.c.WithWaitingStatus(self.c.Tr.RewordingStatus, func(gocui.Task) error {
419+
err := self.c.Git().Rebase.RewordCommit(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), summary, description)
420+
if err != nil {
421+
return err
422+
}
423+
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
424+
})
427425
}
428426

429427
func (self *LocalCommitsController) doRewordEditor() error {

pkg/i18n/english.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ type TranslationSet struct {
384384
RedoingStatus string
385385
CheckingOutStatus string
386386
CommittingStatus string
387+
RewordingStatus string
387388
RevertingStatus string
388389
CreatingFixupCommitStatus string
389390
CommitFiles string
@@ -1425,6 +1426,7 @@ func EnglishTranslationSet() *TranslationSet {
14251426
RedoingStatus: "Redoing",
14261427
CheckingOutStatus: "Checking out",
14271428
CommittingStatus: "Committing",
1429+
RewordingStatus: "Rewording",
14281430
RevertingStatus: "Reverting",
14291431
CreatingFixupCommitStatus: "Creating fixup commit",
14301432
CommitFiles: "Commit files",

0 commit comments

Comments
 (0)