mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-27 23:08:02 +02:00
Split behavior of rendering allBranchesLogCmd and switching to next cmd
This now allows for leaving the status panel and returning back to the same log command. Previously any return to the status panel would result in the next command in the list being shown. Now, you need to press `a`, with a log command being rendered, to rotate to the next allBranchesLogCmd.
This commit is contained in:
parent
a0ec22c251
commit
e67bc45d48
@ -255,18 +255,24 @@ func (self *BranchCommands) Merge(branchName string, opts MergeOpts) error {
|
||||
return self.cmd.New(cmdArgs).Run()
|
||||
}
|
||||
|
||||
func (self *BranchCommands) AllBranchesLogCmdObj() *oscommands.CmdObj {
|
||||
// Only choose between non-empty, non-identical commands
|
||||
candidates := lo.Uniq(lo.WithoutEmpty(self.UserConfig().Git.AllBranchesLogCmds))
|
||||
// Only choose between non-empty, non-identical commands
|
||||
func (self *BranchCommands) allBranchesLogCandidates() []string {
|
||||
return lo.Uniq(lo.WithoutEmpty(self.UserConfig().Git.AllBranchesLogCmds))
|
||||
}
|
||||
|
||||
n := len(candidates)
|
||||
func (self *BranchCommands) AllBranchesLogCmdObj() *oscommands.CmdObj {
|
||||
candidates := self.allBranchesLogCandidates()
|
||||
|
||||
i := self.allBranchesLogCmdIndex
|
||||
self.allBranchesLogCmdIndex = uint8((int(i) + 1) % n)
|
||||
|
||||
return self.cmd.New(str.ToArgv(candidates[i])).DontLog()
|
||||
}
|
||||
|
||||
func (self *BranchCommands) RotateAllBranchesLogIdx() {
|
||||
n := len(self.allBranchesLogCandidates())
|
||||
i := self.allBranchesLogCmdIndex
|
||||
self.allBranchesLogCmdIndex = uint8((int(i) + 1) % n)
|
||||
}
|
||||
|
||||
func (self *BranchCommands) IsBranchMerged(branch *models.Branch, mainBranches *MainBranches) (bool, error) {
|
||||
branchesToCheckAgainst := []string{"HEAD"}
|
||||
if branch.RemoteBranchStoredLocally() {
|
||||
|
@ -60,7 +60,7 @@ func (self *StatusController) GetKeybindings(opts types.KeybindingsOpts) []*type
|
||||
},
|
||||
{
|
||||
Key: opts.GetKey(opts.Config.Status.AllBranchesLogGraph),
|
||||
Handler: func() error { self.showAllBranchLogs(); return nil },
|
||||
Handler: func() error { self.switchToOrRotateAllBranchesLogs(); return nil },
|
||||
Description: self.c.Tr.AllBranchesLogGraph,
|
||||
},
|
||||
}
|
||||
@ -190,6 +190,18 @@ func (self *StatusController) showAllBranchLogs() {
|
||||
})
|
||||
}
|
||||
|
||||
// Switches to the all branches view, or, if already on that view,
|
||||
// rotates to the next command in the list, and then renders it.
|
||||
func (self *StatusController) switchToOrRotateAllBranchesLogs() {
|
||||
// A bit of a hack to ensure we only rotate to the next branch log command
|
||||
// if we currently are looking at a branch log. Otherwise, we should just show
|
||||
// the current index (if we are coming from the dashboard).
|
||||
if self.c.Views().Main.Title == self.c.Tr.LogTitle {
|
||||
self.c.Git().Branch.RotateAllBranchesLogIdx()
|
||||
}
|
||||
self.showAllBranchLogs()
|
||||
}
|
||||
|
||||
func (self *StatusController) showDashboard() {
|
||||
versionStr := "master"
|
||||
version, err := types.ParseVersionNumber(self.c.GetConfig().GetVersion())
|
||||
|
@ -0,0 +1,38 @@
|
||||
package status
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var LogCmdStatusPanelAllBranchesLog = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Cycle between two different log commands in the Status view when it has status panel AllBranchesLog",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Git.AllBranchesLogCmds = []string{`echo "view1"`, `echo "view2"`}
|
||||
config.GetUserConfig().Gui.StatusPanelView = "allBranchesLog"
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Status().
|
||||
Focus()
|
||||
t.Views().Main().Content(Contains("view1"))
|
||||
|
||||
// We head to the branches view and return
|
||||
t.Views().Branches().
|
||||
Focus()
|
||||
t.Views().Status().
|
||||
Focus()
|
||||
|
||||
t.Views().Main().Content(Contains("view1").DoesNotContain("view2"))
|
||||
|
||||
t.Views().Status().
|
||||
Press(keys.Status.AllBranchesLogGraph)
|
||||
t.Views().Main().Content(Contains("view2").DoesNotContain("view1"))
|
||||
|
||||
t.Views().Status().
|
||||
Press(keys.Status.AllBranchesLogGraph)
|
||||
t.Views().Main().Content(Contains("view1").DoesNotContain("view2"))
|
||||
},
|
||||
})
|
@ -360,6 +360,7 @@ var tests = []*components.IntegrationTest{
|
||||
status.ClickToFocus,
|
||||
status.ClickWorkingTreeStateToOpenRebaseOptionsMenu,
|
||||
status.LogCmd,
|
||||
status.LogCmdStatusPanelAllBranchesLog,
|
||||
status.ShowDivergenceFromBaseBranch,
|
||||
submodule.Add,
|
||||
submodule.Enter,
|
||||
|
Loading…
x
Reference in New Issue
Block a user