mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
Add tests demonstrating undesired behavior with update-ref todos for copied branches
These tests succeed here, but have comments explaining which bits are undesired. See next commit for a more detailed explanation why.
This commit is contained in:
parent
7270dea48d
commit
af6d072cc6
4 changed files with 168 additions and 0 deletions
69
pkg/integration/tests/branch/rebase_copied_branch.go
Normal file
69
pkg/integration/tests/branch/rebase_copied_branch.go
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
package branch
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var RebaseCopiedBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Make a copy of a branch, rebase it, check that the original branch is unaffected",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
GitVersion: AtLeast("2.38.0"),
|
||||||
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
|
config.AppState.GitLogShowGraph = "never"
|
||||||
|
},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.
|
||||||
|
EmptyCommit("master 1").
|
||||||
|
EmptyCommit("master 2").
|
||||||
|
NewBranchFrom("branch1", "master^").
|
||||||
|
EmptyCommit("branch 1").
|
||||||
|
EmptyCommit("branch 2").
|
||||||
|
NewBranch("branch2")
|
||||||
|
|
||||||
|
shell.SetConfig("rebase.updateRefs", "true")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Commits().Lines(
|
||||||
|
Contains("CI * branch 2"),
|
||||||
|
Contains("CI branch 1"),
|
||||||
|
Contains("CI master 1"),
|
||||||
|
)
|
||||||
|
|
||||||
|
t.Views().Branches().
|
||||||
|
Focus().
|
||||||
|
Lines(
|
||||||
|
Contains("branch2").IsSelected(),
|
||||||
|
Contains("branch1"),
|
||||||
|
Contains("master"),
|
||||||
|
).
|
||||||
|
NavigateToLine(Contains("master")).
|
||||||
|
Press(keys.Branches.RebaseBranch).
|
||||||
|
Tap(func() {
|
||||||
|
t.ExpectPopup().Menu().
|
||||||
|
Title(Equals("Rebase 'branch2' onto 'master'")).
|
||||||
|
Select(Contains("Simple rebase")).
|
||||||
|
Confirm()
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Views().Commits().Lines(
|
||||||
|
Contains("CI * branch 2"), // wrong, don't want a star here
|
||||||
|
Contains("CI branch 1"),
|
||||||
|
Contains("CI master 2"),
|
||||||
|
Contains("CI master 1"),
|
||||||
|
)
|
||||||
|
|
||||||
|
t.Views().Branches().
|
||||||
|
Focus().
|
||||||
|
NavigateToLine(Contains("branch1")).
|
||||||
|
PressPrimaryAction()
|
||||||
|
|
||||||
|
t.Views().Commits().Lines(
|
||||||
|
Contains("CI * branch 2"), // wrong, don't want a star here
|
||||||
|
Contains("CI branch 1"),
|
||||||
|
Contains("CI master 2"), // wrong, don't want this commit
|
||||||
|
Contains("CI master 1"),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
|
@ -0,0 +1,55 @@
|
||||||
|
package interactive_rebase
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var DropCommitInCopiedBranchWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Drops a commit in a branch that is a copy of another branch, and verify that the other branch is left alone",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
GitVersion: AtLeast("2.38.0"),
|
||||||
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
|
config.AppState.GitLogShowGraph = "never"
|
||||||
|
},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.
|
||||||
|
NewBranch("branch1").
|
||||||
|
CreateNCommits(3).
|
||||||
|
NewBranch("branch2")
|
||||||
|
|
||||||
|
shell.SetConfig("rebase.updateRefs", "true")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Commits().
|
||||||
|
Focus().
|
||||||
|
Lines(
|
||||||
|
Contains("CI * commit 03").IsSelected(),
|
||||||
|
Contains("CI commit 02"),
|
||||||
|
Contains("CI commit 01"),
|
||||||
|
).
|
||||||
|
NavigateToLine(Contains("commit 02")).
|
||||||
|
Press(keys.Universal.Remove).
|
||||||
|
Tap(func() {
|
||||||
|
t.ExpectPopup().Confirmation().
|
||||||
|
Title(Equals("Drop commit")).
|
||||||
|
Content(Equals("Are you sure you want to drop the selected commit(s)?")).
|
||||||
|
Confirm()
|
||||||
|
}).
|
||||||
|
Lines(
|
||||||
|
Contains("CI * commit 03"), // don't want a star here because branch1 should no longer be pointing to it
|
||||||
|
Contains("CI commit 01"),
|
||||||
|
)
|
||||||
|
|
||||||
|
t.Views().Branches().
|
||||||
|
Focus().
|
||||||
|
NavigateToLine(Contains("branch1")).
|
||||||
|
PressPrimaryAction()
|
||||||
|
|
||||||
|
t.Views().Commits().Lines(
|
||||||
|
Contains("CI * commit 03"), // branch1 has changed like branch2, but shouldn't have
|
||||||
|
Contains("CI commit 01"),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
|
@ -0,0 +1,41 @@
|
||||||
|
package interactive_rebase
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var InteractiveRebaseOfCopiedBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Check that interactively rebasing a branch that is a copy of another branch doesn't affect the original branch",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
GitVersion: AtLeast("2.38.0"),
|
||||||
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
|
config.AppState.GitLogShowGraph = "never"
|
||||||
|
},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.
|
||||||
|
NewBranch("branch1").
|
||||||
|
CreateNCommits(3).
|
||||||
|
NewBranch("branch2")
|
||||||
|
|
||||||
|
shell.SetConfig("rebase.updateRefs", "true")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Commits().
|
||||||
|
Focus().
|
||||||
|
Lines(
|
||||||
|
Contains("CI * commit 03"),
|
||||||
|
Contains("CI commit 02"),
|
||||||
|
Contains("CI commit 01"),
|
||||||
|
).
|
||||||
|
NavigateToLine(Contains("commit 01")).
|
||||||
|
Press(keys.Universal.Edit).
|
||||||
|
Lines(
|
||||||
|
Contains("update-ref").Contains("branch1"), // we don't want this
|
||||||
|
Contains("pick").Contains("CI commit 03"),
|
||||||
|
Contains("pick").Contains("CI commit 02"),
|
||||||
|
Contains("CI <-- YOU ARE HERE --- commit 01"),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
|
@ -47,6 +47,7 @@ var tests = []*components.IntegrationTest{
|
||||||
branch.RebaseAbortOnConflict,
|
branch.RebaseAbortOnConflict,
|
||||||
branch.RebaseAndDrop,
|
branch.RebaseAndDrop,
|
||||||
branch.RebaseCancelOnConflict,
|
branch.RebaseCancelOnConflict,
|
||||||
|
branch.RebaseCopiedBranch,
|
||||||
branch.RebaseDoesNotAutosquash,
|
branch.RebaseDoesNotAutosquash,
|
||||||
branch.RebaseFromMarkedBase,
|
branch.RebaseFromMarkedBase,
|
||||||
branch.RebaseToUpstream,
|
branch.RebaseToUpstream,
|
||||||
|
@ -170,6 +171,7 @@ var tests = []*components.IntegrationTest{
|
||||||
interactive_rebase.AmendNonHeadCommitDuringRebase,
|
interactive_rebase.AmendNonHeadCommitDuringRebase,
|
||||||
interactive_rebase.DeleteUpdateRefTodo,
|
interactive_rebase.DeleteUpdateRefTodo,
|
||||||
interactive_rebase.DontShowBranchHeadsForTodoItems,
|
interactive_rebase.DontShowBranchHeadsForTodoItems,
|
||||||
|
interactive_rebase.DropCommitInCopiedBranchWithUpdateRef,
|
||||||
interactive_rebase.DropTodoCommitWithUpdateRef,
|
interactive_rebase.DropTodoCommitWithUpdateRef,
|
||||||
interactive_rebase.DropWithCustomCommentChar,
|
interactive_rebase.DropWithCustomCommentChar,
|
||||||
interactive_rebase.EditFirstCommit,
|
interactive_rebase.EditFirstCommit,
|
||||||
|
@ -178,6 +180,7 @@ var tests = []*components.IntegrationTest{
|
||||||
interactive_rebase.EditTheConflCommit,
|
interactive_rebase.EditTheConflCommit,
|
||||||
interactive_rebase.FixupFirstCommit,
|
interactive_rebase.FixupFirstCommit,
|
||||||
interactive_rebase.FixupSecondCommit,
|
interactive_rebase.FixupSecondCommit,
|
||||||
|
interactive_rebase.InteractiveRebaseOfCopiedBranch,
|
||||||
interactive_rebase.MidRebaseRangeSelect,
|
interactive_rebase.MidRebaseRangeSelect,
|
||||||
interactive_rebase.Move,
|
interactive_rebase.Move,
|
||||||
interactive_rebase.MoveInRebase,
|
interactive_rebase.MoveInRebase,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue