summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-05-30 17:14:02 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-06-01 08:12:45 +0200
commit3284d69886250576b0b1799a0e691fd7bfaba655 (patch)
treeeff53fd6a2cc9582e0c85c00a861949982ea01a5 /pkg
parent116c18e9571bd6708ce56ed41fd84dde25a93de5 (diff)
Add integration test for pushing when the remote is not stored locally
The test needs all three fixes from this branch to succeed.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/integration/tests/sync/force_push_remote_branch_not_stored_locally.go81
-rw-r--r--pkg/integration/tests/test_list.go1
2 files changed, 82 insertions, 0 deletions
diff --git a/pkg/integration/tests/sync/force_push_remote_branch_not_stored_locally.go b/pkg/integration/tests/sync/force_push_remote_branch_not_stored_locally.go
new file mode 100644
index 000000000..d6b8a7cfd
--- /dev/null
+++ b/pkg/integration/tests/sync/force_push_remote_branch_not_stored_locally.go
@@ -0,0 +1,81 @@
+package sync
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var ForcePushRemoteBranchNotStoredLocally = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Push a branch whose remote branch is not stored locally, requiring a force push",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("one")
+ shell.EmptyCommit("two")
+
+ shell.Clone("some-remote")
+
+ // remove the 'two' commit so that we have something to pull from the remote
+ shell.HardReset("HEAD^")
+
+ shell.SetConfig("branch.master.remote", "../some-remote")
+ shell.SetConfig("branch.master.pushRemote", "../some-remote")
+ shell.SetConfig("branch.master.merge", "refs/heads/master")
+
+ shell.CreateFileAndAdd("file1", "file1 content")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Lines(
+ Contains("one"),
+ )
+
+ t.Views().Status().Content(Contains("? repo → master"))
+
+ // We're behind our upstream now, so we expect to be asked to force-push
+ t.Views().Files().IsFocused().Press(keys.Universal.Push)
+
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Force push")).
+ Content(Equals("Your branch has diverged from the remote branch. Press <esc> to cancel, or <enter> to force push.")).
+ Confirm()
+
+ // Make a new local commit
+ t.Views().Files().IsFocused().Press(keys.Files.CommitChanges)
+ t.ExpectPopup().CommitMessagePanel().Type("new").Confirm()
+
+ t.Views().Commits().
+ Lines(
+ Contains("new"),
+ Contains("one"),
+ )
+
+ // Pushing this works without needing to force push
+ t.Views().Files().IsFocused().Press(keys.Universal.Push)
+
+ // Now add the clone as a remote just so that we can check if what we
+ // pushed arrived there correctly
+ t.Views().Remotes().Focus().
+ Press(keys.Universal.New)
+
+ t.ExpectPopup().Prompt().
+ Title(Equals("New remote name:")).Type("some-remote").Confirm()
+ t.ExpectPopup().Prompt().
+ Title(Equals("New remote url:")).Type("../some-remote").Confirm()
+ t.Views().Remotes().Lines(
+ Contains("some-remote").IsSelected(),
+ ).
+ PressEnter()
+
+ t.Views().RemoteBranches().IsFocused().Lines(
+ Contains("master").IsSelected(),
+ ).
+ PressEnter()
+
+ t.Views().SubCommits().IsFocused().Lines(
+ Contains("new"),
+ Contains("one"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index c65db5abc..e1ded611b 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -276,6 +276,7 @@ var tests = []*components.IntegrationTest{
sync.ForcePush,
sync.ForcePushMultipleMatching,
sync.ForcePushMultipleUpstream,
+ sync.ForcePushRemoteBranchNotStoredLocally,
sync.ForcePushTriangular,
sync.Pull,
sync.PullAndSetUpstream,