summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-07-27 18:21:47 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-07-29 14:44:00 +0200
commit6794149ec872764ba0ad2d03d998bcd6ebb95f96 (patch)
treea7abd671722953175274da96aa077033233bee7d /pkg/gui
parenta4772ae606174fb5cf5da2a3530e77f9d42352e4 (diff)
When bisecting, always mark the current commit as good/bad, not the selected
For marking as good or bad, the current commit is pretty much always the one you want to mark, not the selected. It's different for skipping; sometimes you know already that a certain commit doesn't compile, for example, so you might navigate there and mark it as skipped. So in the case that the current commit is not the selected one, we now offer two separate menu entries for skipping, one for the current commit and one for the selected.
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/controllers/bisect_controller.go44
1 files changed, 33 insertions, 11 deletions
diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go
index afa417bb1..7cb36ef26 100644
--- a/pkg/gui/controllers/bisect_controller.go
+++ b/pkg/gui/controllers/bisect_controller.go
@@ -8,6 +8,8 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
+ "github.com/jesseduffield/lazygit/pkg/utils"
+ "github.com/samber/lo"
)
type BisectController struct {
@@ -65,12 +67,18 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
// ref, because we'll be reloading our commits in that case.
waitToReselect := selectCurrentAfter && !self.c.Git().Bisect.ReachableFromStart(info)
+ // If we have a current sha already, then we always want to use that one. If
+ // not, we're still picking the initial commits before we really start, so
+ // use the selected commit in that case.
+ shaToMark := lo.Ternary(info.GetCurrentSha() != "", info.GetCurrentSha(), commit.Sha)
+ shortShaToMark := utils.ShortSha(shaToMark)
+
menuItems := []*types.MenuItem{
{
- Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.NewTerm()),
+ Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortShaToMark, info.NewTerm()),
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.BisectMark)
- if err := self.c.Git().Bisect.Mark(commit.Sha, info.NewTerm()); err != nil {
+ if err := self.c.Git().Bisect.Mark(shaToMark, info.NewTerm()); err != nil {
return self.c.Error(err)
}
@@ -79,10 +87,10 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Key: 'b',
},
{
- Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.OldTerm()),
+ Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortShaToMark, info.OldTerm()),
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.BisectMark)
- if err := self.c.Git().Bisect.Mark(commit.Sha, info.OldTerm()); err != nil {
+ if err := self.c.Git().Bisect.Mark(shaToMark, info.OldTerm()); err != nil {
return self.c.Error(err)
}
@@ -91,10 +99,10 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Key: 'g',
},
{
- Label: fmt.Sprintf(self.c.Tr.Bisect.Skip, commit.ShortSha()),
+ Label: fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, shortShaToMark),
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.BisectSkip)
- if err := self.c.Git().Bisect.Skip(commit.Sha); err != nil {
+ if err := self.c.Git().Bisect.Skip(shaToMark); err != nil {
return self.c.Error(err)
}
@@ -102,14 +110,28 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
},
Key: 's',
},
- {
- Label: self.c.Tr.Bisect.ResetOption,
+ }
+ if info.GetCurrentSha() != "" && info.GetCurrentSha() != commit.Sha {
+ menuItems = append(menuItems, lo.ToPtr(types.MenuItem{
+ Label: fmt.Sprintf(self.c.Tr.Bisect.SkipSelected, commit.ShortSha()),
OnPress: func() error {
- return self.c.Helpers().Bisect.Reset()
+ self.c.LogAction(self.c.Tr.Actions.BisectSkip)
+ if err := self.c.Git().Bisect.Skip(commit.Sha); err != nil {
+ return self.c.Error(err)
+ }
+
+ return self.afterMark(selectCurrentAfter, waitToReselect)
},
- Key: 'r',
- },
+ Key: 'S',
+ }))
}
+ menuItems = append(menuItems, lo.ToPtr(types.MenuItem{
+ Label: self.c.Tr.Bisect.ResetOption,
+ OnPress: func() error {
+ return self.c.Helpers().Bisect.Reset()
+ },
+ Key: 'r',
+ }))
return self.c.Menu(types.CreateMenuOptions{
Title: self.c.Tr.Bisect.BisectMenuTitle,