summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-13 18:36:39 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-13 18:40:34 +1000
commitb61ca21a8419c05fe5876bc020a40408321634c6 (patch)
tree4188be8c61bc51376ee8589ddde2c8b593ea0bb1 /pkg/integration
parent1ded318666aedfa256d0436bce665c8fcfd6a1f2 (diff)
Allow checking for merge conflicts after running a custom command
We have a use-case to rebind 'm' to the merge action in the branches panel. There's three ways to handle this: 1) For all global keybindings, define a per-panel key that invokes it 2) Give a name to all controller actions and allow them to be invoked in custom commands 3) Allow checking for merge conflicts after running a custom command so that users can add their own 'git merge' custom command that matches the in-built action Option 1 is hairy, Option 2 though good for users introduces new backwards compatibility issues that I don't want to do right now, and option 3 is trivially easy to implement so that's what I'm doing. I've put this under an 'after' key so that we can add more things later. I'm imagining other things like being able to move the cursor to a newly added item etc. I considered always running this hook by default but I'd rather not: it's matching on the output text and I'd rather something like that be explicitly opted-into to avoid cases where we erroneously believe that there are conflicts.
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/tests/custom_commands/check_for_conflicts.go40
-rw-r--r--pkg/integration/tests/test_list.go1
2 files changed, 41 insertions, 0 deletions
diff --git a/pkg/integration/tests/custom_commands/check_for_conflicts.go b/pkg/integration/tests/custom_commands/check_for_conflicts.go
new file mode 100644
index 000000000..cb8ac7c77
--- /dev/null
+++ b/pkg/integration/tests/custom_commands/check_for_conflicts.go
@@ -0,0 +1,40 @@
+package custom_commands
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+ "github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
+)
+
+var CheckForConflicts = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Run a command and check for conflicts after",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupRepo: func(shell *Shell) {
+ shared.MergeConflictsSetup(shell)
+ },
+ SetupConfig: func(cfg *config.AppConfig) {
+ cfg.UserConfig.CustomCommands = []config.CustomCommand{
+ {
+ Key: "m",
+ Context: "localBranches",
+ Command: "git merge {{ .SelectedLocalBranch.Name | quote }}",
+ After: config.CustomCommandAfterHook{
+ CheckForConflicts: true,
+ },
+ },
+ }
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Branches().
+ Focus().
+ TopLines(
+ Contains("first-change-branch"),
+ Contains("second-change-branch"),
+ ).
+ NavigateToLine(Contains("second-change-branch")).
+ Press("m")
+
+ t.Common().AcknowledgeConflicts()
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index 55085f989..af0ac1c5b 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -75,6 +75,7 @@ var tests = []*components.IntegrationTest{
conflicts.UndoChooseHunk,
custom_commands.BasicCmdAtRuntime,
custom_commands.BasicCmdFromConfig,
+ custom_commands.CheckForConflicts,
custom_commands.ComplexCmdAtRuntime,
custom_commands.FormPrompts,
custom_commands.MenuFromCommand,