summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-02-19 15:08:35 +0100
committerStefan Haller <stefan@haller-berlin.de>2023-02-20 07:40:04 +0100
commitdd61c49a1544e44da4602a7643723e4c6c240648 (patch)
tree79ae1dc6fdce6ea07748b01d2b92c13d94ec46c8 /pkg/gui/controllers
parent1c3db24e447b63d6507c2dceb0d21db768d1a6f5 (diff)
Better error message for trying to squash or fixup the first commit
It's not so much the total number of commits that matters here, it's just whether we are on the first one. (This includes the other condition.) This allows us to get rid of the condition in rebase.go.
Diffstat (limited to 'pkg/gui/controllers')
-rw-r--r--pkg/gui/controllers/local_commits_controller.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go
index a9fe7a190..42920bf81 100644
--- a/pkg/gui/controllers/local_commits_controller.go
+++ b/pkg/gui/controllers/local_commits_controller.go
@@ -148,8 +148,8 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
}
func (self *LocalCommitsController) squashDown(commit *models.Commit) error {
- if len(self.model.Commits) <= 1 {
- return self.c.ErrorMsg(self.c.Tr.YouNoCommitsToSquash)
+ if self.context().GetSelectedLineIdx() >= len(self.model.Commits)-1 {
+ return self.c.ErrorMsg(self.c.Tr.CannotSquashOrFixupFirstCommit)
}
applied, err := self.handleMidRebaseCommand("squash", commit)
@@ -173,8 +173,8 @@ func (self *LocalCommitsController) squashDown(commit *models.Commit) error {
}
func (self *LocalCommitsController) fixup(commit *models.Commit) error {
- if len(self.model.Commits) <= 1 {
- return self.c.ErrorMsg(self.c.Tr.YouNoCommitsToSquash)
+ if self.context().GetSelectedLineIdx() >= len(self.model.Commits)-1 {
+ return self.c.ErrorMsg(self.c.Tr.CannotSquashOrFixupFirstCommit)
}
applied, err := self.handleMidRebaseCommand("fixup", commit)