1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-22 04:42:37 +03:00
Files
lazygit/pkg/integration/tests/branch/merge_fast_forward.go
Stefan Haller 62854026a3 Add no-ff merge option
This will put whatever git's default merge variant is as the first menu item,
and add a second item which is the opposite (no-ff if the default is ff, and
vice versa).

If users prefer to always have the same option first no matter whether it's
applicable, they can make ff always appear first by setting git's "merge.ff"
config to "true" or "only", or by setting lazygit's "git.merging.args" config to
"--ff" or "--ff-only"; if they want no-ff to appear first, they can do that by
setting git's "merge.ff" config to "false", or by setting lazygit's
"git.merging.args" config to "--no-ff". Which of these they choose depends on
whether they want the config to also apply to other git clients including the
cli, or only to lazygit.
2025-10-19 21:24:28 +02:00

69 lines
1.8 KiB
Go

package branch
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var MergeFastForward = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Merge a branch into another using fast-forward merge",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical"
},
SetupRepo: func(shell *Shell) {
shell.NewBranch("original-branch").
EmptyCommit("one").
NewBranch("branch1").
EmptyCommit("branch1").
Checkout("original-branch").
NewBranchFrom("branch2", "original-branch").
EmptyCommit("branch2").
Checkout("original-branch")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Lines(
Contains("original-branch").IsSelected(),
Contains("branch1"),
Contains("branch2"),
).
SelectNextItem().
Press(keys.Branches.MergeIntoCurrentBranch)
t.ExpectPopup().Menu().
Title(Equals("Merge")).
TopLines(
Contains("Regular merge (fast-forward)"),
Contains("Regular merge (with merge commit)"),
).
Select(Contains("Regular merge (fast-forward)")).
Confirm()
t.Views().Commits().
Lines(
Contains("branch1").IsSelected(),
Contains("one"),
)
// Check that branch2 can't be merged using fast-forward
t.Views().Branches().
Focus().
NavigateToLine(Contains("branch2")).
Press(keys.Branches.MergeIntoCurrentBranch)
t.ExpectPopup().Menu().
Title(Equals("Merge")).
TopLines(
Contains("Regular merge (with merge commit)"),
Contains("Regular merge (fast-forward)"),
).
Select(Contains("Regular merge (fast-forward)")).
Confirm()
t.ExpectToast(Contains("Cannot fast-forward 'original-branch' to 'branch2'"))
},
})