Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs-master/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ git:
# to 40 to disable truncation.
truncateCopiedCommitHashesTo: 12

# Extra arguments to pass to `git flow <type> finish <name>`, e.g.
# ["--keepremote"]
gitFlowFinishArgs: []

# Periodic update checks
update:
# One of: 'prompt' (default) | 'background' | 'never'
Expand Down
4 changes: 3 additions & 1 deletion pkg/commands/git_commands/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func (self *FlowCommands) FinishCmdObj(branchName string) (*oscommands.CmdObj, e
return nil, errors.New(self.Tr.NotAGitFlowBranch)
}

cmdArgs := NewGitCmd("flow").Arg(branchType, "finish", suffix).ToArgv()
cmdArgs := NewGitCmd("flow").Arg(branchType, "finish", suffix).
Arg(self.UserConfig().Git.GitFlowFinishArgs...).
ToArgv()

return self.cmd.New(cmdArgs), nil
}
Expand Down
33 changes: 32 additions & 1 deletion pkg/commands/git_commands/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/jesseduffield/lazygit/pkg/commands/git_config"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -41,6 +42,7 @@ func TestFinishCmdObj(t *testing.T) {
expected []string
expectedError string
gitConfigMockResponses map[string]string
userConfig *config.UserConfig
}{
{
testName: "not a git flow branch",
Expand All @@ -65,12 +67,41 @@ func TestFinishCmdObj(t *testing.T) {
"--local --get-regexp gitflow.prefix": "gitflow.prefix.feature feature/",
},
},
{
testName: "feature branch with extra finish args",
branchName: "feature/mybranch",
expected: []string{"git", "flow", "feature", "finish", "mybranch", "--keepremote"},
expectedError: "",
gitConfigMockResponses: map[string]string{
"--local --get-regexp gitflow.prefix": "gitflow.prefix.feature feature/",
},
userConfig: &config.UserConfig{
Git: config.GitConfig{
GitFlowFinishArgs: []string{"--keepremote"},
},
},
},
{
testName: "feature branch with multiple extra finish args",
branchName: "feature/mybranch",
expected: []string{"git", "flow", "feature", "finish", "mybranch", "--keepremote", "--keeplocal"},
expectedError: "",
gitConfigMockResponses: map[string]string{
"--local --get-regexp gitflow.prefix": "gitflow.prefix.feature feature/",
},
userConfig: &config.UserConfig{
Git: config.GitConfig{
GitFlowFinishArgs: []string{"--keepremote", "--keeplocal"},
},
},
},
}

for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) {
instance := buildFlowCommands(commonDeps{
gitConfig: git_config.NewFakeGitConfig(s.gitConfigMockResponses),
gitConfig: git_config.NewFakeGitConfig(s.gitConfigMockResponses),
userConfig: s.userConfig,
})

cmd, err := instance.FinishCmdObj(s.branchName)
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ type GitConfig struct {
RemoteBranchSortOrder string `yaml:"remoteBranchSortOrder" jsonschema:"enum=date,enum=alphabetical"`
// When copying commit hashes to the clipboard, truncate them to this length. Set to 40 to disable truncation.
TruncateCopiedCommitHashesTo int `yaml:"truncateCopiedCommitHashesTo"`
// Extra arguments to pass to `git flow <type> finish <name>`, e.g. ["--keepremote"]
GitFlowFinishArgs []string `yaml:"gitFlowFinishArgs"`
}

type PagerType string
Expand Down Expand Up @@ -858,6 +860,7 @@ func GetDefaultConfig() *UserConfig {
BranchPrefix: "",
ParseEmoji: false,
TruncateCopiedCommitHashesTo: 12,
GitFlowFinishArgs: []string{},
},
Refresher: RefresherConfig{
RefreshInterval: 10,
Expand Down
7 changes: 7 additions & 0 deletions schema-master/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,13 @@
"type": "integer",
"description": "When copying commit hashes to the clipboard, truncate them to this length. Set to 40 to disable truncation.",
"default": 12
},
"gitFlowFinishArgs": {
"items": {
"type": "string"
},
"type": "array",
"description": "Extra arguments to pass to `git flow \u003ctype\u003e finish \u003cname\u003e`, e.g. [\"--keepremote\"]"
}
},
"additionalProperties": false,
Expand Down
Loading