mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
Allow cycling between multiple log commands
- Introduced a new optional user config command, allBranchesLogCmds - When pressing 'a' in the Status view, cycle between non-empty, non-identical log commands - There will always be at least one command to run, since allBranhesLogCmd has a default - Update documentation & write an integration test - Update translation string
This commit is contained in:
parent
3d14893c65
commit
be21328c69
8 changed files with 65 additions and 6 deletions
|
@ -306,7 +306,8 @@ git:
|
||||||
# Command used when displaying the current branch git log in the main window
|
# Command used when displaying the current branch git log in the main window
|
||||||
branchLogCmd: git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --
|
branchLogCmd: git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --
|
||||||
|
|
||||||
# Command used to display git log of all branches in the main window
|
# Command used to display git log of all branches in the main window.
|
||||||
|
# Deprecated: User `allBranchesLogCmds` instead.
|
||||||
allBranchesLogCmd: git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium
|
allBranchesLogCmd: git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium
|
||||||
|
|
||||||
# If true, do not spawn a separate process when using GPG
|
# If true, do not spawn a separate process when using GPG
|
||||||
|
|
|
@ -309,7 +309,7 @@ If you would instead like to start an interactive rebase from the selected commi
|
||||||
| `` e `` | Edit config file | Open file in external editor. |
|
| `` e `` | Edit config file | Open file in external editor. |
|
||||||
| `` u `` | Check for update | |
|
| `` u `` | Check for update | |
|
||||||
| `` <enter> `` | Switch to a recent repo | |
|
| `` <enter> `` | Switch to a recent repo | |
|
||||||
| `` a `` | Show all branch logs | |
|
| `` a `` | Show/cycle all branch logs | |
|
||||||
|
|
||||||
## Sub-commits
|
## Sub-commits
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,12 @@ import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/mgutz/str"
|
"github.com/mgutz/str"
|
||||||
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BranchCommands struct {
|
type BranchCommands struct {
|
||||||
*GitCommon
|
*GitCommon
|
||||||
|
allBranchesLogCmdIndex uint8 // keeps track of current all branches log command
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBranchCommands(gitCommon *GitCommon) *BranchCommands {
|
func NewBranchCommands(gitCommon *GitCommon) *BranchCommands {
|
||||||
|
@ -244,5 +246,17 @@ func (self *BranchCommands) Merge(branchName string, opts MergeOpts) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BranchCommands) AllBranchesLogCmdObj() oscommands.ICmdObj {
|
func (self *BranchCommands) AllBranchesLogCmdObj() oscommands.ICmdObj {
|
||||||
return self.cmd.New(str.ToArgv(self.UserConfig.Git.AllBranchesLogCmd)).DontLog()
|
// Only choose between non-empty, non-identical commands
|
||||||
|
candidates := lo.Uniq(lo.WithoutEmpty(append([]string{
|
||||||
|
self.UserConfig.Git.AllBranchesLogCmd,
|
||||||
|
},
|
||||||
|
self.UserConfig.Git.AllBranchesLogCmds...,
|
||||||
|
)))
|
||||||
|
|
||||||
|
n := len(candidates)
|
||||||
|
|
||||||
|
i := self.allBranchesLogCmdIndex
|
||||||
|
self.allBranchesLogCmdIndex = uint8((int(i) + 1) % n)
|
||||||
|
|
||||||
|
return self.cmd.New(str.ToArgv(candidates[i])).DontLog()
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,8 +226,11 @@ type GitConfig struct {
|
||||||
FetchAll bool `yaml:"fetchAll"`
|
FetchAll bool `yaml:"fetchAll"`
|
||||||
// Command used when displaying the current branch git log in the main window
|
// Command used when displaying the current branch git log in the main window
|
||||||
BranchLogCmd string `yaml:"branchLogCmd"`
|
BranchLogCmd string `yaml:"branchLogCmd"`
|
||||||
// Command used to display git log of all branches in the main window
|
// Command used to display git log of all branches in the main window.
|
||||||
|
// Deprecated: User `allBranchesLogCmds` instead.
|
||||||
AllBranchesLogCmd string `yaml:"allBranchesLogCmd"`
|
AllBranchesLogCmd string `yaml:"allBranchesLogCmd"`
|
||||||
|
// Commands used to display git log of all branches in the main window, they will be cycled in order of appearance
|
||||||
|
AllBranchesLogCmds []string `yaml:"allBranchesLogCmds"`
|
||||||
// If true, do not spawn a separate process when using GPG
|
// If true, do not spawn a separate process when using GPG
|
||||||
OverrideGpg bool `yaml:"overrideGpg"`
|
OverrideGpg bool `yaml:"overrideGpg"`
|
||||||
// If true, do not allow force pushes
|
// If true, do not allow force pushes
|
||||||
|
|
|
@ -1208,7 +1208,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||||
MergeBranchTooltip: "View options for merging the selected item into the current branch (regular merge, squash merge)",
|
MergeBranchTooltip: "View options for merging the selected item into the current branch (regular merge, squash merge)",
|
||||||
ConfirmQuit: `Are you sure you want to quit?`,
|
ConfirmQuit: `Are you sure you want to quit?`,
|
||||||
SwitchRepo: `Switch to a recent repo`,
|
SwitchRepo: `Switch to a recent repo`,
|
||||||
AllBranchesLogGraph: `Show all branch logs`,
|
AllBranchesLogGraph: `Show/cycle all branch logs`,
|
||||||
UnsupportedGitService: `Unsupported git service`,
|
UnsupportedGitService: `Unsupported git service`,
|
||||||
CreatePullRequest: `Create pull request`,
|
CreatePullRequest: `Create pull request`,
|
||||||
CopyPullRequestURL: `Copy pull request URL to clipboard`,
|
CopyPullRequestURL: `Copy pull request URL to clipboard`,
|
||||||
|
|
33
pkg/integration/tests/status/log_cmd.go
Normal file
33
pkg/integration/tests/status/log_cmd.go
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
package status
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var LogCmd = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Cycle between two different log commands in the Status view",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
|
config.UserConfig.Git.AllBranchesLogCmd = `echo "view1"`
|
||||||
|
config.UserConfig.Git.AllBranchesLogCmds = []string{`echo "view2"`}
|
||||||
|
},
|
||||||
|
SetupRepo: func(shell *Shell) {},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Status().
|
||||||
|
Focus().
|
||||||
|
Press(keys.Status.AllBranchesLogGraph)
|
||||||
|
t.Views().Main().Content(Contains("view1"))
|
||||||
|
|
||||||
|
t.Views().Status().
|
||||||
|
Focus().
|
||||||
|
Press(keys.Status.AllBranchesLogGraph)
|
||||||
|
t.Views().Main().Content(Contains("view2").DoesNotContain("view1"))
|
||||||
|
|
||||||
|
t.Views().Status().
|
||||||
|
Focus().
|
||||||
|
Press(keys.Status.AllBranchesLogGraph)
|
||||||
|
t.Views().Main().Content(Contains("view1").DoesNotContain("view2"))
|
||||||
|
},
|
||||||
|
})
|
|
@ -286,6 +286,7 @@ var tests = []*components.IntegrationTest{
|
||||||
status.ClickRepoNameToOpenReposMenu,
|
status.ClickRepoNameToOpenReposMenu,
|
||||||
status.ClickToFocus,
|
status.ClickToFocus,
|
||||||
status.ClickWorkingTreeStateToOpenRebaseOptionsMenu,
|
status.ClickWorkingTreeStateToOpenRebaseOptionsMenu,
|
||||||
|
status.LogCmd,
|
||||||
status.ShowDivergenceFromBaseBranch,
|
status.ShowDivergenceFromBaseBranch,
|
||||||
submodule.Add,
|
submodule.Add,
|
||||||
submodule.Enter,
|
submodule.Enter,
|
||||||
|
|
|
@ -580,9 +580,16 @@
|
||||||
},
|
},
|
||||||
"allBranchesLogCmd": {
|
"allBranchesLogCmd": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Command used to display git log of all branches in the main window",
|
"description": "Command used to display git log of all branches in the main window.\nDeprecated: User `allBranchesLogCmds` instead.",
|
||||||
"default": "git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium"
|
"default": "git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium"
|
||||||
},
|
},
|
||||||
|
"allBranchesLogCmds": {
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": "array",
|
||||||
|
"description": "Commands used to display git log of all branches in the main window, they will be cycled in order of appearance"
|
||||||
|
},
|
||||||
"overrideGpg": {
|
"overrideGpg": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "If true, do not spawn a separate process when using GPG",
|
"description": "If true, do not spawn a separate process when using GPG",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue