Skip to content

Commit 737a99b

Browse files
Chris McDonnellstefanhaller
authored andcommitted
Add integration tests showing resetting to duplicate named tags and branches
1 parent 122d6e5 commit 737a99b

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package branch
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var ResetToDuplicateNamedTag = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Hard reset to a branch when a tag shares the same name",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {},
13+
SetupRepo: func(shell *Shell) {
14+
shell.NewBranch("current-branch")
15+
16+
shell.EmptyCommit("other-branch-tag commit")
17+
shell.CreateLightweightTag("other-branch", "HEAD")
18+
19+
shell.EmptyCommit("other-branch commit")
20+
shell.NewBranch("other-branch")
21+
22+
shell.Checkout("current-branch")
23+
shell.EmptyCommit("current-branch commit")
24+
},
25+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
26+
t.Views().Commits().Lines(
27+
Contains("current-branch commit"),
28+
Contains("other-branch commit"),
29+
Contains("other-branch-tag commit"),
30+
)
31+
32+
t.Views().Branches().
33+
Focus().
34+
Lines(
35+
Contains("current-branch").IsSelected(),
36+
Contains("other-branch"),
37+
).
38+
SelectNextItem().
39+
Press(keys.Commits.ViewResetOptions)
40+
41+
t.ExpectPopup().Menu().
42+
Title(Contains("Reset to other-branch")).
43+
Select(Contains("Hard reset")).
44+
Confirm()
45+
46+
t.Views().Commits().
47+
Lines(
48+
Contains("other-branch commit"),
49+
Contains("other-branch-tag commit"),
50+
)
51+
},
52+
})
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package tag
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var ResetToDuplicateNamedBranch = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Hard reset to a tag when a branch shares the same name",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {},
13+
SetupRepo: func(shell *Shell) {
14+
shell.NewBranch("current-branch")
15+
16+
shell.EmptyCommit("other-branch-tag commit")
17+
shell.CreateLightweightTag("other-branch", "HEAD")
18+
19+
shell.EmptyCommit("other-branch commit")
20+
shell.NewBranch("other-branch")
21+
22+
shell.Checkout("current-branch")
23+
shell.EmptyCommit("current-branch commit")
24+
},
25+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
26+
t.Views().Commits().Lines(
27+
Contains("current-branch commit"),
28+
Contains("other-branch commit"),
29+
Contains("other-branch-tag commit"),
30+
)
31+
32+
t.Views().Tags().
33+
Focus().
34+
Lines(
35+
Contains("other-branch").IsSelected(),
36+
).
37+
Press(keys.Commits.ViewResetOptions)
38+
39+
t.ExpectPopup().Menu().
40+
Title(Contains("Reset to other-branch")).
41+
Select(Contains("Hard reset")).
42+
Confirm()
43+
44+
t.Views().Commits().Lines(
45+
Contains("other-branch-tag commit"),
46+
)
47+
},
48+
})

pkg/integration/tests/test_list.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ var tests = []*components.IntegrationTest{
7171
branch.RebaseToUpstream,
7272
branch.Rename,
7373
branch.Reset,
74+
branch.ResetToDuplicateNamedTag,
7475
branch.ResetToUpstream,
7576
branch.SelectCommitsOfCurrentBranch,
7677
branch.SetUpstream,
@@ -406,6 +407,7 @@ var tests = []*components.IntegrationTest{
406407
tag.ForceTagAnnotated,
407408
tag.ForceTagLightweight,
408409
tag.Reset,
410+
tag.ResetToDuplicateNamedBranch,
409411
ui.Accordion,
410412
ui.DisableSwitchTabWithPanelJumpKeys,
411413
ui.EmptyMenu,

0 commit comments

Comments
 (0)