1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-08 22:36:49 +02:00

Add integration tests showing resetting to duplicate named tags and branches

This commit is contained in:
Chris McDonnell
2025-05-24 21:00:31 -04:00
committed by Stefan Haller
parent 122d6e5f0d
commit 737a99b1c8
3 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,52 @@
package branch
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ResetToDuplicateNamedTag = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Hard reset to a branch when a tag shares the same name",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.NewBranch("current-branch")
shell.EmptyCommit("other-branch-tag commit")
shell.CreateLightweightTag("other-branch", "HEAD")
shell.EmptyCommit("other-branch commit")
shell.NewBranch("other-branch")
shell.Checkout("current-branch")
shell.EmptyCommit("current-branch commit")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().Lines(
Contains("current-branch commit"),
Contains("other-branch commit"),
Contains("other-branch-tag commit"),
)
t.Views().Branches().
Focus().
Lines(
Contains("current-branch").IsSelected(),
Contains("other-branch"),
).
SelectNextItem().
Press(keys.Commits.ViewResetOptions)
t.ExpectPopup().Menu().
Title(Contains("Reset to other-branch")).
Select(Contains("Hard reset")).
Confirm()
t.Views().Commits().
Lines(
Contains("other-branch commit"),
Contains("other-branch-tag commit"),
)
},
})

View File

@ -0,0 +1,48 @@
package tag
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ResetToDuplicateNamedBranch = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Hard reset to a tag when a branch shares the same name",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.NewBranch("current-branch")
shell.EmptyCommit("other-branch-tag commit")
shell.CreateLightweightTag("other-branch", "HEAD")
shell.EmptyCommit("other-branch commit")
shell.NewBranch("other-branch")
shell.Checkout("current-branch")
shell.EmptyCommit("current-branch commit")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().Lines(
Contains("current-branch commit"),
Contains("other-branch commit"),
Contains("other-branch-tag commit"),
)
t.Views().Tags().
Focus().
Lines(
Contains("other-branch").IsSelected(),
).
Press(keys.Commits.ViewResetOptions)
t.ExpectPopup().Menu().
Title(Contains("Reset to other-branch")).
Select(Contains("Hard reset")).
Confirm()
t.Views().Commits().Lines(
Contains("other-branch-tag commit"),
)
},
})

View File

@ -71,6 +71,7 @@ var tests = []*components.IntegrationTest{
branch.RebaseToUpstream, branch.RebaseToUpstream,
branch.Rename, branch.Rename,
branch.Reset, branch.Reset,
branch.ResetToDuplicateNamedTag,
branch.ResetToUpstream, branch.ResetToUpstream,
branch.SelectCommitsOfCurrentBranch, branch.SelectCommitsOfCurrentBranch,
branch.SetUpstream, branch.SetUpstream,
@ -406,6 +407,7 @@ var tests = []*components.IntegrationTest{
tag.ForceTagAnnotated, tag.ForceTagAnnotated,
tag.ForceTagLightweight, tag.ForceTagLightweight,
tag.Reset, tag.Reset,
tag.ResetToDuplicateNamedBranch,
ui.Accordion, ui.Accordion,
ui.DisableSwitchTabWithPanelJumpKeys, ui.DisableSwitchTabWithPanelJumpKeys,
ui.EmptyMenu, ui.EmptyMenu,