1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-22 04:42:37 +03:00
Files
lazygit/pkg/integration/tests/ui/mode_specific_keybinding_suggestions.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

119 lines
3.4 KiB
Go

package ui
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
)
var ModeSpecificKeybindingSuggestions = NewIntegrationTest(NewIntegrationTestArgs{
Description: "When in various modes, we should corresponding keybinding suggestions onscreen",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateNCommits(2)
shell.NewBranch("base-branch")
shared.MergeConflictsSetup(shell)
shell.Checkout("base-branch")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
rebaseSuggestion := "View rebase options: m"
cherryPickSuggestion := "Paste (cherry-pick): V"
bisectSuggestion := "View bisect options: b"
customPatchSuggestion := "View custom patch options: <c-p>"
mergeSuggestion := "View merge options: m"
t.Views().Commits().
Focus().
Lines(
Contains("commit 02").IsSelected(),
Contains("commit 01"),
).
Tap(func() {
// These suggestions are mode-specific so are not shown by default
t.Views().Options().Content(
DoesNotContain(rebaseSuggestion).
DoesNotContain(mergeSuggestion).
DoesNotContain(cherryPickSuggestion).
DoesNotContain(bisectSuggestion).
DoesNotContain(customPatchSuggestion),
)
}).
// Start an interactive rebase
Press(keys.Universal.Edit).
Tap(func() {
// Confirm the rebase suggestion now appears
t.Views().Options().Content(Contains(rebaseSuggestion))
}).
Press(keys.Commits.CherryPickCopy).
Tap(func() {
// Confirm the cherry pick suggestion now appears
t.Views().Options().Content(Contains(cherryPickSuggestion))
// Importantly, we show multiple of these suggestions at once
t.Views().Options().Content(Contains(rebaseSuggestion))
}).
// Cancel the cherry pick
PressEscape().
Tap(func() {
t.Views().Options().Content(DoesNotContain(cherryPickSuggestion))
}).
// Cancel the rebase
Tap(func() {
t.Common().AbortRebase()
t.Views().Options().Content(DoesNotContain(rebaseSuggestion))
}).
Press(keys.Commits.ViewBisectOptions).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Bisect")).
Select(MatchesRegexp("Mark.* as bad")).
Confirm()
t.Views().Options().Content(Contains(bisectSuggestion))
// Cancel bisect
t.Common().ResetBisect()
t.Views().Options().Content(DoesNotContain(bisectSuggestion))
}).
// Enter commit files view
PressEnter()
t.Views().CommitFiles().
IsFocused().
// Add a commit file to the patch
Press(keys.Universal.Select).
Tap(func() {
t.Views().Options().Content(Contains(customPatchSuggestion))
t.Common().ResetCustomPatch()
t.Views().Options().Content(DoesNotContain(customPatchSuggestion))
})
// Test merge options suggestion
t.Views().Branches().
Focus().
NavigateToLine(Contains("first-change-branch")).
Press(keys.Universal.Select).
NavigateToLine(Contains("second-change-branch")).
Press(keys.Branches.MergeIntoCurrentBranch).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Merge")).
Select(Contains("Regular merge (with merge commit)")).
Confirm()
t.Common().AcknowledgeConflicts()
t.Views().Options().Content(Contains(mergeSuggestion))
t.Common().AbortMerge()
t.Views().Options().Content(DoesNotContain(mergeSuggestion))
})
},
})