mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Add config for auto-forwarding branches after fetching
This commit is contained in:
@ -0,0 +1,54 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var FetchAndAutoForwardBranchesAllBranches = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Fetch from remote and auto-forward branches with config set to 'allBranches'",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Git.AutoForwardBranches = "allBranches"
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateNCommits(3)
|
||||
shell.NewBranch("feature")
|
||||
shell.NewBranch("diverged")
|
||||
shell.CloneIntoRemote("origin")
|
||||
shell.SetBranchUpstream("master", "origin/master")
|
||||
shell.SetBranchUpstream("feature", "origin/feature")
|
||||
shell.SetBranchUpstream("diverged", "origin/diverged")
|
||||
shell.Checkout("master")
|
||||
shell.HardReset("HEAD^")
|
||||
shell.Checkout("feature")
|
||||
shell.HardReset("HEAD~2")
|
||||
shell.Checkout("diverged")
|
||||
shell.HardReset("HEAD~2")
|
||||
shell.EmptyCommit("local")
|
||||
shell.NewBranch("checked-out")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
Contains("checked-out").IsSelected(),
|
||||
Contains("diverged ↓2↑1"),
|
||||
Contains("feature ↓2").DoesNotContain("↑"),
|
||||
Contains("master ↓1").DoesNotContain("↑"),
|
||||
)
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Files.Fetch)
|
||||
|
||||
// AutoForwardBranches is "allBranches": both master and feature get forwarded
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
Contains("checked-out").IsSelected(),
|
||||
Contains("diverged ↓2↑1"),
|
||||
Contains("feature ✓"),
|
||||
Contains("master ✓"),
|
||||
)
|
||||
},
|
||||
})
|
@ -0,0 +1,54 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var FetchAndAutoForwardBranchesNone = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Fetch from remote and auto-forward branches with config set to 'none'",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Git.AutoForwardBranches = "none"
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateNCommits(3)
|
||||
shell.NewBranch("feature")
|
||||
shell.NewBranch("diverged")
|
||||
shell.CloneIntoRemote("origin")
|
||||
shell.SetBranchUpstream("master", "origin/master")
|
||||
shell.SetBranchUpstream("feature", "origin/feature")
|
||||
shell.SetBranchUpstream("diverged", "origin/diverged")
|
||||
shell.Checkout("master")
|
||||
shell.HardReset("HEAD^")
|
||||
shell.Checkout("feature")
|
||||
shell.HardReset("HEAD~2")
|
||||
shell.Checkout("diverged")
|
||||
shell.HardReset("HEAD~2")
|
||||
shell.EmptyCommit("local")
|
||||
shell.NewBranch("checked-out")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
Contains("checked-out").IsSelected(),
|
||||
Contains("diverged ↓2↑1"),
|
||||
Contains("feature ↓2").DoesNotContain("↑"),
|
||||
Contains("master ↓1").DoesNotContain("↑"),
|
||||
)
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Files.Fetch)
|
||||
|
||||
// AutoForwardBranches is "none": nothing should happen
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
Contains("checked-out").IsSelected(),
|
||||
Contains("diverged ↓2↑1"),
|
||||
Contains("feature ↓2").DoesNotContain("↑"),
|
||||
Contains("master ↓1").DoesNotContain("↑"),
|
||||
)
|
||||
},
|
||||
})
|
@ -0,0 +1,54 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var FetchAndAutoForwardBranchesOnlyMainBranches = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Fetch from remote and auto-forward branches with config set to 'onlyMainBranches'",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Git.AutoForwardBranches = "onlyMainBranches"
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateNCommits(3)
|
||||
shell.NewBranch("feature")
|
||||
shell.NewBranch("diverged")
|
||||
shell.CloneIntoRemote("origin")
|
||||
shell.SetBranchUpstream("master", "origin/master")
|
||||
shell.SetBranchUpstream("feature", "origin/feature")
|
||||
shell.SetBranchUpstream("diverged", "origin/diverged")
|
||||
shell.Checkout("master")
|
||||
shell.HardReset("HEAD^")
|
||||
shell.Checkout("feature")
|
||||
shell.HardReset("HEAD~2")
|
||||
shell.Checkout("diverged")
|
||||
shell.HardReset("HEAD~2")
|
||||
shell.EmptyCommit("local")
|
||||
shell.NewBranch("checked-out")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
Contains("checked-out").IsSelected(),
|
||||
Contains("diverged ↓2↑1"),
|
||||
Contains("feature ↓2").DoesNotContain("↑"),
|
||||
Contains("master ↓1").DoesNotContain("↑"),
|
||||
)
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Files.Fetch)
|
||||
|
||||
// AutoForwardBranches is "onlyMainBranches": master gets forwarded, but feature doesn't
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
Contains("checked-out").IsSelected(),
|
||||
Contains("diverged ↓2↑1"),
|
||||
Contains("feature ↓2").DoesNotContain("↑"),
|
||||
Contains("master ✓"),
|
||||
)
|
||||
},
|
||||
})
|
Reference in New Issue
Block a user