mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
Add --all to "git fetch" command when not fetching a specific remote
This commit is contained in:
parent
697157f5d5
commit
31a2ea1f19
4 changed files with 37 additions and 8 deletions
|
@ -95,15 +95,17 @@ func TestSyncPush(t *testing.T) {
|
|||
|
||||
func TestSyncFetch(t *testing.T) {
|
||||
type scenario struct {
|
||||
testName string
|
||||
opts FetchOptions
|
||||
test func(oscommands.ICmdObj)
|
||||
testName string
|
||||
opts FetchOptions
|
||||
fetchAllConfig bool
|
||||
test func(oscommands.ICmdObj)
|
||||
}
|
||||
|
||||
scenarios := []scenario{
|
||||
{
|
||||
testName: "Fetch in foreground",
|
||||
opts: FetchOptions{Background: false},
|
||||
testName: "Fetch in foreground (all=false)",
|
||||
opts: FetchOptions{Background: false},
|
||||
fetchAllConfig: false,
|
||||
test: func(cmdObj oscommands.ICmdObj) {
|
||||
assert.True(t, cmdObj.ShouldLog())
|
||||
assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.PROMPT)
|
||||
|
@ -111,20 +113,42 @@ func TestSyncFetch(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
testName: "Fetch in background",
|
||||
opts: FetchOptions{Background: true},
|
||||
testName: "Fetch in foreground (all=true)",
|
||||
opts: FetchOptions{Background: false},
|
||||
fetchAllConfig: true,
|
||||
test: func(cmdObj oscommands.ICmdObj) {
|
||||
assert.True(t, cmdObj.ShouldLog())
|
||||
assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.PROMPT)
|
||||
assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--all"})
|
||||
},
|
||||
},
|
||||
{
|
||||
testName: "Fetch in background (all=false)",
|
||||
opts: FetchOptions{Background: true},
|
||||
fetchAllConfig: false,
|
||||
test: func(cmdObj oscommands.ICmdObj) {
|
||||
assert.False(t, cmdObj.ShouldLog())
|
||||
assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.FAIL)
|
||||
assert.Equal(t, cmdObj.Args(), []string{"git", "fetch"})
|
||||
},
|
||||
},
|
||||
{
|
||||
testName: "Fetch in background (all=true)",
|
||||
opts: FetchOptions{Background: true},
|
||||
fetchAllConfig: true,
|
||||
test: func(cmdObj oscommands.ICmdObj) {
|
||||
assert.False(t, cmdObj.ShouldLog())
|
||||
assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.FAIL)
|
||||
assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--all"})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
s := s
|
||||
t.Run(s.testName, func(t *testing.T) {
|
||||
instance := buildSyncCommands(commonDeps{})
|
||||
instance.UserConfig.Git.FetchAll = s.fetchAllConfig
|
||||
s.test(instance.FetchCmdObj(s.opts))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue