Skip to content

Commit

Permalink
Add test demonstrating the problem
Browse files Browse the repository at this point in the history
When there's a branch with the same name as the tag, the branch gets checked out
instead of the tag.
  • Loading branch information
stefanhaller committed Jan 9, 2024
1 parent af5e25c commit 2b97f0f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package tag

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var CheckoutWhenBranchWithSameNameExists = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Checkout a tag when there's a branch with the same name",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.NewBranch("tag")
shell.Checkout("master")
shell.EmptyCommit("two")
shell.CreateLightweightTag("tag", "HEAD")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Tags().
Focus().
Lines(
Contains("tag").IsSelected(),
).
PressPrimaryAction() // checkout tag

t.Views().Branches().IsFocused().Lines(
/* EXPECTED:
Contains("HEAD detached at tag").IsSelected(),
Contains("master"),
Contains("tag"),
ACTUAL: */
Contains("* tag").DoesNotContain("HEAD detached").IsSelected(),
Contains("master"),
)
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ var tests = []*components.IntegrationTest{
sync.PushWithCredentialPrompt,
sync.RenameBranchAndPull,
tag.Checkout,
tag.CheckoutWhenBranchWithSameNameExists,
tag.CreateWhileCommitting,
tag.CrudAnnotated,
tag.CrudLightweight,
Expand Down

0 comments on commit 2b97f0f

Please sign in to comment.