summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-24 17:16:59 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-30 18:35:23 +1000
commitb3060065d9a776c755903a1297ab3954c01853a8 (patch)
tree84891e7b8be47a734b8e709fce779c4257e14d48 /pkg/integration
parenta313b1670496e1e73745b5a6a922432fb81ce0e6 (diff)
Support fastforwarding worktree
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/components/shell.go7
-rw-r--r--pkg/integration/tests/test_list.go1
-rw-r--r--pkg/integration/tests/worktree/fast_forward_worktree_branch.go52
3 files changed, 60 insertions, 0 deletions
diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go
index bfa82c45e..741135e2f 100644
--- a/pkg/integration/components/shell.go
+++ b/pkg/integration/components/shell.go
@@ -261,6 +261,13 @@ func (self *Shell) AddWorktree(base string, path string, newBranchName string) *
})
}
+// add worktree and have it checkout the base branch
+func (self *Shell) AddWorktreeCheckout(base string, path string) *Shell {
+ return self.RunCommand([]string{
+ "git", "worktree", "add", path, base,
+ })
+}
+
func (self *Shell) AddFileInWorktree(worktreePath string) *Shell {
self.CreateFile(filepath.Join(worktreePath, "content"), "content")
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index 0e619f8b9..981f705e2 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -227,6 +227,7 @@ var tests = []*components.IntegrationTest{
worktree.Crud,
worktree.CustomCommand,
worktree.DetachWorktreeFromBranch,
+ worktree.FastForwardWorktreeBranch,
worktree.ForceRemoveWorktree,
worktree.Rebase,
worktree.RemoveWorktreeFromBranch,
diff --git a/pkg/integration/tests/worktree/fast_forward_worktree_branch.go b/pkg/integration/tests/worktree/fast_forward_worktree_branch.go
new file mode 100644
index 000000000..99d32f40a
--- /dev/null
+++ b/pkg/integration/tests/worktree/fast_forward_worktree_branch.go
@@ -0,0 +1,52 @@
+package worktree
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var FastForwardWorktreeBranch = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Fast-forward a linked worktree branch from another worktree",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ // both main and linked worktree will have changed to fast-foward
+ shell.NewBranch("mybranch")
+ shell.CreateFileAndAdd("README.md", "hello world")
+ shell.Commit("initial commit")
+ shell.EmptyCommit("two")
+ shell.EmptyCommit("three")
+ shell.NewBranch("newbranch")
+
+ shell.CloneIntoRemote("origin")
+ shell.SetBranchUpstream("mybranch", "origin/mybranch")
+ shell.SetBranchUpstream("newbranch", "origin/newbranch")
+
+ // remove the 'three' commit so that we have something to pull from the remote
+ shell.HardReset("HEAD^")
+ shell.Checkout("mybranch")
+ shell.HardReset("HEAD^")
+
+ shell.AddWorktreeCheckout("newbranch", "../linked-worktree")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Branches().
+ Focus().
+ Lines(
+ Contains("mybranch").Contains("↓1").IsSelected(),
+ Contains("newbranch (worktree)").Contains("↓1"),
+ ).
+ Press(keys.Branches.FastForward).
+ Lines(
+ Contains("mybranch").Contains("✓").IsSelected(),
+ Contains("newbranch (worktree)").Contains("↓1"),
+ ).
+ NavigateToLine(Contains("newbranch (worktree)")).
+ Press(keys.Branches.FastForward).
+ Lines(
+ Contains("mybranch").Contains("✓"),
+ Contains("newbranch (worktree)").Contains("✓").IsSelected(),
+ )
+ },
+})