diff --git a/pkg/integration/tests/branch/delete.go b/pkg/integration/tests/branch/delete.go new file mode 100644 index 000000000..46df9a457 --- /dev/null +++ b/pkg/integration/tests/branch/delete.go @@ -0,0 +1,40 @@ +package branch + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var Delete = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Try to delete the checked out branch first (to no avail), and then delete another branch.", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + EmptyCommit("blah"). + NewBranch("branch-one"). + NewBranch("branch-two") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + input.SwitchToBranchesWindow() + assert.CurrentViewName("localBranches") + + assert.MatchSelectedLine(Contains("branch-two")) + input.PressKeys(keys.Universal.Remove) + assert.InAlert() + assert.MatchCurrentViewContent(Contains("You cannot delete the checked out branch!")) + + input.Confirm() + + input.NextItem() + assert.MatchSelectedLine(Contains("branch-one")) + input.PressKeys(keys.Universal.Remove) + assert.InConfirm() + assert.MatchCurrentViewContent(Contains("Are you sure you want to delete the branch 'branch-one'?")) + input.Confirm() + assert.CurrentViewName("localBranches") + assert.MatchSelectedLine(Contains("master")) + assert.MatchCurrentViewContent(NotContains("branch-one")) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 6fcd8249f..88f6b40da 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -24,6 +24,7 @@ var tests = []*components.IntegrationTest{ commit.Commit, commit.NewBranch, branch.Suggestions, + branch.Delete, interactive_rebase.One, custom_commands.Basic, custom_commands.MultiplePrompts, diff --git a/test/integration/branchDelete/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/branchDelete/expected/repo/.git_keep/COMMIT_EDITMSG deleted file mode 100644 index dc3ab4abe..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/COMMIT_EDITMSG +++ /dev/null @@ -1 +0,0 @@ -file0 diff --git a/test/integration/branchDelete/expected/repo/.git_keep/HEAD b/test/integration/branchDelete/expected/repo/.git_keep/HEAD deleted file mode 100644 index ba0879fe6..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/old-branch-3 diff --git a/test/integration/branchDelete/expected/repo/.git_keep/index b/test/integration/branchDelete/expected/repo/.git_keep/index deleted file mode 100644 index 9743f9410..000000000 Binary files a/test/integration/branchDelete/expected/repo/.git_keep/index and /dev/null differ diff --git a/test/integration/branchDelete/expected/repo/.git_keep/logs/HEAD b/test/integration/branchDelete/expected/repo/.git_keep/logs/HEAD deleted file mode 100644 index d70cecff2..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/logs/HEAD +++ /dev/null @@ -1,7 +0,0 @@ -0000000000000000000000000000000000000000 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 commit (initial): file0 -21b436d66d2c515ad17285e53d9e6380d599b044 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 checkout: moving from master to new-branch -21b436d66d2c515ad17285e53d9e6380d599b044 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 checkout: moving from new-branch to new-branch-2 -21b436d66d2c515ad17285e53d9e6380d599b044 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 checkout: moving from new-branch-2 to new-branch-3 -21b436d66d2c515ad17285e53d9e6380d599b044 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 checkout: moving from new-branch-3 to old-branch -21b436d66d2c515ad17285e53d9e6380d599b044 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 checkout: moving from old-branch to old-branch-2 -21b436d66d2c515ad17285e53d9e6380d599b044 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 checkout: moving from old-branch-2 to old-branch-3 diff --git a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/master deleted file mode 100644 index 2e2382c42..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 commit (initial): file0 diff --git a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/new-branch b/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/new-branch deleted file mode 100644 index 2050baa52..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/new-branch +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 branch: Created from HEAD diff --git a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/new-branch-2 b/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/new-branch-2 deleted file mode 100644 index 2050baa52..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/new-branch-2 +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 branch: Created from HEAD diff --git a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/new-branch-3 b/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/new-branch-3 deleted file mode 100644 index 2050baa52..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/new-branch-3 +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 branch: Created from HEAD diff --git a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/old-branch b/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/old-branch deleted file mode 100644 index 2050baa52..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/old-branch +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 branch: Created from HEAD diff --git a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/old-branch-3 b/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/old-branch-3 deleted file mode 100644 index 2050baa52..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/logs/refs/heads/old-branch-3 +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 21b436d66d2c515ad17285e53d9e6380d599b044 CI 1617684680 +1000 branch: Created from HEAD diff --git a/test/integration/branchDelete/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 b/test/integration/branchDelete/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 deleted file mode 100644 index 79fcadf67..000000000 Binary files a/test/integration/branchDelete/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 and /dev/null differ diff --git a/test/integration/branchDelete/expected/repo/.git_keep/objects/21/b436d66d2c515ad17285e53d9e6380d599b044 b/test/integration/branchDelete/expected/repo/.git_keep/objects/21/b436d66d2c515ad17285e53d9e6380d599b044 deleted file mode 100644 index db6a55b3b..000000000 Binary files a/test/integration/branchDelete/expected/repo/.git_keep/objects/21/b436d66d2c515ad17285e53d9e6380d599b044 and /dev/null differ diff --git a/test/integration/branchDelete/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da b/test/integration/branchDelete/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da deleted file mode 100644 index 06c9cb73d..000000000 Binary files a/test/integration/branchDelete/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da and /dev/null differ diff --git a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/master b/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/master deleted file mode 100644 index cf15cb775..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -21b436d66d2c515ad17285e53d9e6380d599b044 diff --git a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/new-branch b/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/new-branch deleted file mode 100644 index cf15cb775..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/new-branch +++ /dev/null @@ -1 +0,0 @@ -21b436d66d2c515ad17285e53d9e6380d599b044 diff --git a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/new-branch-2 b/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/new-branch-2 deleted file mode 100644 index cf15cb775..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/new-branch-2 +++ /dev/null @@ -1 +0,0 @@ -21b436d66d2c515ad17285e53d9e6380d599b044 diff --git a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/new-branch-3 b/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/new-branch-3 deleted file mode 100644 index cf15cb775..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/new-branch-3 +++ /dev/null @@ -1 +0,0 @@ -21b436d66d2c515ad17285e53d9e6380d599b044 diff --git a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/old-branch b/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/old-branch deleted file mode 100644 index cf15cb775..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/old-branch +++ /dev/null @@ -1 +0,0 @@ -21b436d66d2c515ad17285e53d9e6380d599b044 diff --git a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/old-branch-3 b/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/old-branch-3 deleted file mode 100644 index cf15cb775..000000000 --- a/test/integration/branchDelete/expected/repo/.git_keep/refs/heads/old-branch-3 +++ /dev/null @@ -1 +0,0 @@ -21b436d66d2c515ad17285e53d9e6380d599b044 diff --git a/test/integration/branchDelete/expected/repo/file0 b/test/integration/branchDelete/expected/repo/file0 deleted file mode 100644 index 38143ad4a..000000000 --- a/test/integration/branchDelete/expected/repo/file0 +++ /dev/null @@ -1 +0,0 @@ -test0 diff --git a/test/integration/branchDelete/recording.json b/test/integration/branchDelete/recording.json deleted file mode 100644 index e0f28d911..000000000 --- a/test/integration/branchDelete/recording.json +++ /dev/null @@ -1 +0,0 @@ -{"KeyEvents":[{"Timestamp":483,"Mod":0,"Key":259,"Ch":0},{"Timestamp":787,"Mod":0,"Key":256,"Ch":100},{"Timestamp":2021,"Mod":0,"Key":27,"Ch":0},{"Timestamp":2436,"Mod":0,"Key":258,"Ch":0},{"Timestamp":2779,"Mod":0,"Key":256,"Ch":100},{"Timestamp":3275,"Mod":0,"Key":13,"Ch":13},{"Timestamp":3971,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/branchDelete/setup.sh b/test/integration/branchDelete/setup.sh deleted file mode 100644 index d67fa9291..000000000 --- a/test/integration/branchDelete/setup.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -set -e - -cd $1 - -git init - -git config user.email "CI@example.com" -git config user.name "CI" - -echo test0 > file0 -git add . -git commit -am file0 - -git checkout -b new-branch -git checkout -b new-branch-2 -git checkout -b new-branch-3 -git checkout -b old-branch -git checkout -b old-branch-2 -git checkout -b old-branch-3 diff --git a/test/integration/branchDelete/test.json b/test/integration/branchDelete/test.json deleted file mode 100644 index fafad1962..000000000 --- a/test/integration/branchDelete/test.json +++ /dev/null @@ -1 +0,0 @@ -{ "description": "Checking out a branch with name suggestions", "speed": 100 } diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/branch/delete/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..907b30816 --- /dev/null +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +blah diff --git a/test/integration/branchDelete/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/branch/delete/expected/repo/.git_keep/FETCH_HEAD similarity index 100% rename from test/integration/branchDelete/expected/repo/.git_keep/FETCH_HEAD rename to test/integration_new/branch/delete/expected/repo/.git_keep/FETCH_HEAD diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/HEAD b/test/integration_new/branch/delete/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..62c2c3bd5 --- /dev/null +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/branch-two diff --git a/test/integration/branchDelete/expected/repo/.git_keep/config b/test/integration_new/branch/delete/expected/repo/.git_keep/config similarity index 87% rename from test/integration/branchDelete/expected/repo/.git_keep/config rename to test/integration_new/branch/delete/expected/repo/.git_keep/config index 8ae104545..8a748ce32 100644 --- a/test/integration/branchDelete/expected/repo/.git_keep/config +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/config @@ -8,3 +8,5 @@ [user] email = CI@example.com name = CI +[commit] + gpgSign = false diff --git a/test/integration/branchDelete/expected/repo/.git_keep/description b/test/integration_new/branch/delete/expected/repo/.git_keep/description similarity index 100% rename from test/integration/branchDelete/expected/repo/.git_keep/description rename to test/integration_new/branch/delete/expected/repo/.git_keep/description diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/index b/test/integration_new/branch/delete/expected/repo/.git_keep/index new file mode 100644 index 000000000..65d675154 Binary files /dev/null and b/test/integration_new/branch/delete/expected/repo/.git_keep/index differ diff --git a/test/integration/branchDelete/expected/repo/.git_keep/info/exclude b/test/integration_new/branch/delete/expected/repo/.git_keep/info/exclude similarity index 100% rename from test/integration/branchDelete/expected/repo/.git_keep/info/exclude rename to test/integration_new/branch/delete/expected/repo/.git_keep/info/exclude diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/logs/HEAD b/test/integration_new/branch/delete/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..8cc1747b6 --- /dev/null +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 a7222d091ed91af493b7173e4b09dd2de085031d CI 1661162427 +1000 commit (initial): blah +a7222d091ed91af493b7173e4b09dd2de085031d a7222d091ed91af493b7173e4b09dd2de085031d CI 1661162427 +1000 checkout: moving from master to branch-one +a7222d091ed91af493b7173e4b09dd2de085031d a7222d091ed91af493b7173e4b09dd2de085031d CI 1661162427 +1000 checkout: moving from branch-one to branch-two diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/logs/refs/heads/branch-one b/test/integration_new/branch/delete/expected/repo/.git_keep/logs/refs/heads/branch-one new file mode 100644 index 000000000..6de773cbd --- /dev/null +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/logs/refs/heads/branch-one @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 a7222d091ed91af493b7173e4b09dd2de085031d CI 1661162427 +1000 branch: Created from HEAD diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/logs/refs/heads/branch-two b/test/integration_new/branch/delete/expected/repo/.git_keep/logs/refs/heads/branch-two new file mode 100644 index 000000000..6de773cbd --- /dev/null +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/logs/refs/heads/branch-two @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 a7222d091ed91af493b7173e4b09dd2de085031d CI 1661162427 +1000 branch: Created from HEAD diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/branch/delete/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..608657ff8 --- /dev/null +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 a7222d091ed91af493b7173e4b09dd2de085031d CI 1661162427 +1000 commit (initial): blah diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/integration_new/branch/delete/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 new file mode 100644 index 000000000..adf64119a Binary files /dev/null and b/test/integration_new/branch/delete/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 differ diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/objects/a7/222d091ed91af493b7173e4b09dd2de085031d b/test/integration_new/branch/delete/expected/repo/.git_keep/objects/a7/222d091ed91af493b7173e4b09dd2de085031d new file mode 100644 index 000000000..363c8b858 Binary files /dev/null and b/test/integration_new/branch/delete/expected/repo/.git_keep/objects/a7/222d091ed91af493b7173e4b09dd2de085031d differ diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/refs/heads/branch-one b/test/integration_new/branch/delete/expected/repo/.git_keep/refs/heads/branch-one new file mode 100644 index 000000000..74ab83e50 --- /dev/null +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/refs/heads/branch-one @@ -0,0 +1 @@ +a7222d091ed91af493b7173e4b09dd2de085031d diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/refs/heads/branch-two b/test/integration_new/branch/delete/expected/repo/.git_keep/refs/heads/branch-two new file mode 100644 index 000000000..74ab83e50 --- /dev/null +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/refs/heads/branch-two @@ -0,0 +1 @@ +a7222d091ed91af493b7173e4b09dd2de085031d diff --git a/test/integration_new/branch/delete/expected/repo/.git_keep/refs/heads/master b/test/integration_new/branch/delete/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..74ab83e50 --- /dev/null +++ b/test/integration_new/branch/delete/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +a7222d091ed91af493b7173e4b09dd2de085031d