From 2b3d457aa44821a7d0c1705a510a5567e44a07da Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 27 Mar 2022 11:22:16 +1100 Subject: [PATCH] honour push.default matching config value --- pkg/gui/controllers/sync_controller.go | 74 ++++++++++-------- .../expected/.git_keep/COMMIT_EDITMSG | 1 + .../expected/.git_keep/FETCH_HEAD | 2 + .../forcePushMultiple/expected/.git_keep/HEAD | 1 + .../expected/.git_keep/ORIG_HEAD | 1 + .../expected/.git_keep/config | 21 +++++ .../expected/.git_keep/description | 1 + .../expected/.git_keep/index | Bin 0 -> 209 bytes .../expected/.git_keep/info/exclude | 7 ++ .../expected/.git_keep/logs/HEAD | 10 +++ .../expected/.git_keep/logs/refs/heads/master | 4 + .../.git_keep/logs/refs/heads/other_branch | 3 + .../.git_keep/logs/refs/remotes/origin/master | 3 + .../logs/refs/remotes/origin/other_branch | 3 + .../0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 | Bin 0 -> 52 bytes .../16/d8875e19987b16f1991a41fd3f4536d16f7cb4 | 2 + .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../2b/173c861df433fa43ffad13f80c8b312c5c8bce | Bin 0 -> 103 bytes .../42/d408cffcc087da21115f9ebc29e9765a2beb83 | 3 + .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../a7/341a59f0ddeef969e69fb6368266d22b0f2416 | Bin 0 -> 77 bytes .../b8/2ed4a67bef9ef50807adf409f103ef7b0832ab | Bin 0 -> 149 bytes .../ce/0848710343a75263ea72cb5bdfa666b9ecda68 | Bin 0 -> 103 bytes .../d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 | Bin 0 -> 21 bytes .../d3/708eeec2b9d69acbe87862330e844e85f77de1 | Bin 0 -> 149 bytes .../df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b | Bin 0 -> 21 bytes .../expected/.git_keep/refs/heads/master | 1 + .../.git_keep/refs/heads/other_branch | 1 + .../.git_keep/refs/remotes/origin/master | 1 + .../refs/remotes/origin/other_branch | 1 + .../forcePushMultiple/expected/myfile1 | 1 + .../forcePushMultiple/expected/myfile2 | 1 + .../forcePushMultiple/expected_remote/HEAD | 1 + .../forcePushMultiple/expected_remote/config | 8 ++ .../expected_remote/description | 1 + .../expected_remote/info/exclude | 7 ++ .../0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 | Bin 0 -> 52 bytes .../16/d8875e19987b16f1991a41fd3f4536d16f7cb4 | 2 + .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../2b/173c861df433fa43ffad13f80c8b312c5c8bce | Bin 0 -> 103 bytes .../42/d408cffcc087da21115f9ebc29e9765a2beb83 | 3 + .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../a7/341a59f0ddeef969e69fb6368266d22b0f2416 | Bin 0 -> 77 bytes .../b8/2ed4a67bef9ef50807adf409f103ef7b0832ab | Bin 0 -> 149 bytes .../ce/0848710343a75263ea72cb5bdfa666b9ecda68 | Bin 0 -> 103 bytes .../d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 | Bin 0 -> 21 bytes .../d3/708eeec2b9d69acbe87862330e844e85f77de1 | Bin 0 -> 149 bytes .../df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b | Bin 0 -> 21 bytes .../expected_remote/packed-refs | 3 + .../expected_remote/refs/heads/master | 1 + .../expected_remote/refs/heads/other_branch | 1 + .../forcePushMultiple/recording.json | 1 + test/integration/forcePushMultiple/setup.sh | 54 +++++++++++++ test/integration/forcePushMultiple/test.json | 4 + 54 files changed, 196 insertions(+), 32 deletions(-) create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/FETCH_HEAD create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/HEAD create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/ORIG_HEAD create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/config create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/description create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/index create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/info/exclude create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/logs/HEAD create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/logs/refs/heads/master create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/logs/refs/heads/other_branch create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/logs/refs/remotes/origin/master create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/logs/refs/remotes/origin/other_branch create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/16/d8875e19987b16f1991a41fd3f4536d16f7cb4 create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/42/d408cffcc087da21115f9ebc29e9765a2beb83 create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/b8/2ed4a67bef9ef50807adf409f103ef7b0832ab create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/ce/0848710343a75263ea72cb5bdfa666b9ecda68 create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/d3/708eeec2b9d69acbe87862330e844e85f77de1 create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/refs/heads/master create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/refs/heads/other_branch create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/refs/remotes/origin/master create mode 100644 test/integration/forcePushMultiple/expected/.git_keep/refs/remotes/origin/other_branch create mode 100644 test/integration/forcePushMultiple/expected/myfile1 create mode 100644 test/integration/forcePushMultiple/expected/myfile2 create mode 100644 test/integration/forcePushMultiple/expected_remote/HEAD create mode 100644 test/integration/forcePushMultiple/expected_remote/config create mode 100644 test/integration/forcePushMultiple/expected_remote/description create mode 100644 test/integration/forcePushMultiple/expected_remote/info/exclude create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/16/d8875e19987b16f1991a41fd3f4536d16f7cb4 create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/42/d408cffcc087da21115f9ebc29e9765a2beb83 create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/b8/2ed4a67bef9ef50807adf409f103ef7b0832ab create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/ce/0848710343a75263ea72cb5bdfa666b9ecda68 create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/d3/708eeec2b9d69acbe87862330e844e85f77de1 create mode 100644 test/integration/forcePushMultiple/expected_remote/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b create mode 100644 test/integration/forcePushMultiple/expected_remote/packed-refs create mode 100644 test/integration/forcePushMultiple/expected_remote/refs/heads/master create mode 100644 test/integration/forcePushMultiple/expected_remote/refs/heads/other_branch create mode 100644 test/integration/forcePushMultiple/recording.json create mode 100644 test/integration/forcePushMultiple/setup.sh create mode 100644 test/integration/forcePushMultiple/test.json diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index 8501c5484..38f8db733 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -1,6 +1,7 @@ package controllers import ( + "errors" "fmt" "strings" @@ -74,13 +75,8 @@ func (self *SyncController) branchCheckedOut(f func(*models.Branch) error) func( func (self *SyncController) push(currentBranch *models.Branch) error { // if we have pullables we'll ask if the user wants to force push if currentBranch.IsTrackingRemote() { - opts := pushOpts{ - force: false, - upstreamRemote: currentBranch.UpstreamRemote, - upstreamBranch: currentBranch.UpstreamBranch, - } + opts := pushOpts{} if currentBranch.HasCommitsToPull() { - opts.force = true return self.requestToForcePush(opts) } else { return self.pushAux(opts) @@ -90,21 +86,15 @@ func (self *SyncController) push(currentBranch *models.Branch) error { return self.pushAux(pushOpts{setUpstream: true}) } else { return self.promptForUpstream(currentBranch, func(upstream string) error { - var upstreamBranch, upstreamRemote string - split := strings.Split(upstream, " ") - if len(split) == 2 { - upstreamRemote = split[0] - upstreamBranch = split[1] - } else { - upstreamRemote = upstream - upstreamBranch = "" + upstreamRemote, upstreamBranch, err := self.parseUpstream(upstream) + if err != nil { + return self.c.Error(err) } return self.pushAux(pushOpts{ - force: false, + setUpstream: true, upstreamRemote: upstreamRemote, upstreamBranch: upstreamBranch, - setUpstream: true, }) }) } @@ -117,27 +107,46 @@ func (self *SyncController) pull(currentBranch *models.Branch) error { // if we have no upstream branch we need to set that first if !currentBranch.IsTrackingRemote() { return self.promptForUpstream(currentBranch, func(upstream string) error { - var upstreamBranch, upstreamRemote string - split := strings.Split(upstream, " ") - if len(split) != 2 { - return self.c.ErrorMsg(self.c.Tr.InvalidUpstream) + if err := self.setCurrentBranchUpstream(upstream); err != nil { + return self.c.Error(err) } - upstreamRemote = split[0] - upstreamBranch = split[1] - - if err := self.git.Branch.SetCurrentBranchUpstream(upstreamRemote, upstreamBranch); err != nil { - errorMessage := err.Error() - if strings.Contains(errorMessage, "does not exist") { - errorMessage = fmt.Sprintf("upstream branch %s not found.\nIf you expect it to exist, you should fetch (with 'f').\nOtherwise, you should push (with 'shift+P')", upstream) - } - return self.c.ErrorMsg(errorMessage) - } - return self.PullAux(PullFilesOptions{UpstreamRemote: upstreamRemote, UpstreamBranch: upstreamBranch, Action: action}) + return self.PullAux(PullFilesOptions{Action: action}) }) } - return self.PullAux(PullFilesOptions{UpstreamRemote: currentBranch.UpstreamRemote, UpstreamBranch: currentBranch.UpstreamBranch, Action: action}) + return self.PullAux(PullFilesOptions{Action: action}) +} + +func (self *SyncController) setCurrentBranchUpstream(upstream string) error { + upstreamRemote, upstreamBranch, err := self.parseUpstream(upstream) + if err != nil { + return err + } + + if err := self.git.Branch.SetCurrentBranchUpstream(upstreamRemote, upstreamBranch); err != nil { + if strings.Contains(err.Error(), "does not exist") { + return fmt.Errorf( + "upstream branch %s/%s not found.\nIf you expect it to exist, you should fetch (with 'f').\nOtherwise, you should push (with 'shift+P')", + upstreamRemote, upstreamBranch, + ) + } + return err + } + return nil +} + +func (self *SyncController) parseUpstream(upstream string) (string, string, error) { + var upstreamBranch, upstreamRemote string + split := strings.Split(upstream, " ") + if len(split) != 2 { + return "", "", errors.New(self.c.Tr.InvalidUpstream) + } + + upstreamRemote = split[0] + upstreamBranch = split[1] + + return upstreamRemote, upstreamBranch, nil } func (self *SyncController) promptForUpstream(currentBranch *models.Branch, onConfirm func(string) error) error { @@ -229,6 +238,7 @@ func (self *SyncController) requestToForcePush(opts pushOpts) error { Title: self.c.Tr.ForcePush, Prompt: self.c.Tr.ForcePushPrompt, HandleConfirm: func() error { + opts.force = true return self.pushAux(opts) }, }) diff --git a/test/integration/forcePushMultiple/expected/.git_keep/COMMIT_EDITMSG b/test/integration/forcePushMultiple/expected/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..51be8ec3d --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +myfile4 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/FETCH_HEAD b/test/integration/forcePushMultiple/expected/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..d56304e09 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/FETCH_HEAD @@ -0,0 +1,2 @@ +b82ed4a67bef9ef50807adf409f103ef7b0832ab branch 'master' of ../actual_remote +d3708eeec2b9d69acbe87862330e844e85f77de1 not-for-merge branch 'other_branch' of ../actual_remote diff --git a/test/integration/forcePushMultiple/expected/.git_keep/HEAD b/test/integration/forcePushMultiple/expected/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/forcePushMultiple/expected/.git_keep/ORIG_HEAD b/test/integration/forcePushMultiple/expected/.git_keep/ORIG_HEAD new file mode 100644 index 000000000..3774ff3d1 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/ORIG_HEAD @@ -0,0 +1 @@ +d3708eeec2b9d69acbe87862330e844e85f77de1 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/config b/test/integration/forcePushMultiple/expected/.git_keep/config new file mode 100644 index 000000000..740ff301f --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/config @@ -0,0 +1,21 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + email = CI@example.com + name = CI +[push] + default = matching +[remote "origin"] + url = ../actual_remote + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master +[branch "other_branch"] + remote = origin + merge = refs/heads/other_branch diff --git a/test/integration/forcePushMultiple/expected/.git_keep/description b/test/integration/forcePushMultiple/expected/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/forcePushMultiple/expected/.git_keep/index b/test/integration/forcePushMultiple/expected/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..375819d60017e3e32da674025180ba89508246c7 GIT binary patch literal 209 zcmZ?q402{*U|<5_B>Q#j8jJQmhtZ4-46ICZb>$cs8kaCIFn$H95dmVhrF$O#RZYF| zB_cG6C*SEpfLBZRRR;Fl%CyX!R70QwkbcdpmqK7P)ErZEb0m0v7&R#EJNI(cqVTHz zmRH*IE!1J=7y-=*337D>Qj!ct3I<%uO{5|}+ 1648340487 +1100 commit (initial): myfile1 +16d8875e19987b16f1991a41fd3f4536d16f7cb4 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 commit: myfile2 +42d408cffcc087da21115f9ebc29e9765a2beb83 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 checkout: moving from master to other_branch +42d408cffcc087da21115f9ebc29e9765a2beb83 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 checkout: moving from other_branch to master +42d408cffcc087da21115f9ebc29e9765a2beb83 b82ed4a67bef9ef50807adf409f103ef7b0832ab CI 1648340487 +1100 commit: myfile3 +b82ed4a67bef9ef50807adf409f103ef7b0832ab 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 reset: moving to HEAD^ +42d408cffcc087da21115f9ebc29e9765a2beb83 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 checkout: moving from master to other_branch +42d408cffcc087da21115f9ebc29e9765a2beb83 d3708eeec2b9d69acbe87862330e844e85f77de1 CI 1648340487 +1100 commit: myfile4 +d3708eeec2b9d69acbe87862330e844e85f77de1 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 reset: moving to HEAD^ +42d408cffcc087da21115f9ebc29e9765a2beb83 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 checkout: moving from other_branch to master diff --git a/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/heads/master b/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..15de170c8 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/heads/master @@ -0,0 +1,4 @@ +0000000000000000000000000000000000000000 16d8875e19987b16f1991a41fd3f4536d16f7cb4 CI 1648340487 +1100 commit (initial): myfile1 +16d8875e19987b16f1991a41fd3f4536d16f7cb4 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 commit: myfile2 +42d408cffcc087da21115f9ebc29e9765a2beb83 b82ed4a67bef9ef50807adf409f103ef7b0832ab CI 1648340487 +1100 commit: myfile3 +b82ed4a67bef9ef50807adf409f103ef7b0832ab 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 reset: moving to HEAD^ diff --git a/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/heads/other_branch b/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/heads/other_branch new file mode 100644 index 000000000..78ea80b06 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/heads/other_branch @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 branch: Created from HEAD +42d408cffcc087da21115f9ebc29e9765a2beb83 d3708eeec2b9d69acbe87862330e844e85f77de1 CI 1648340487 +1100 commit: myfile4 +d3708eeec2b9d69acbe87862330e844e85f77de1 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 reset: moving to HEAD^ diff --git a/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/remotes/origin/master b/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/remotes/origin/master new file mode 100644 index 000000000..dd0a1b736 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/remotes/origin/master @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 fetch origin: storing head +42d408cffcc087da21115f9ebc29e9765a2beb83 b82ed4a67bef9ef50807adf409f103ef7b0832ab CI 1648340487 +1100 update by push +b82ed4a67bef9ef50807adf409f103ef7b0832ab 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340489 +1100 update by push diff --git a/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/remotes/origin/other_branch b/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/remotes/origin/other_branch new file mode 100644 index 000000000..ca4e1389e --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/logs/refs/remotes/origin/other_branch @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340487 +1100 fetch origin: storing head +42d408cffcc087da21115f9ebc29e9765a2beb83 d3708eeec2b9d69acbe87862330e844e85f77de1 CI 1648340487 +1100 update by push +d3708eeec2b9d69acbe87862330e844e85f77de1 42d408cffcc087da21115f9ebc29e9765a2beb83 CI 1648340489 +1100 update by push diff --git a/test/integration/forcePushMultiple/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 b/test/integration/forcePushMultiple/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 new file mode 100644 index 0000000000000000000000000000000000000000..7f2ebf4eeb6ad6875bcc2a2b91ca3345ee06b45e GIT binary patch literal 52 zcmb`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/forcePushMultiple/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 new file mode 100644 index 0000000000000000000000000000000000000000..96d2e71a6af75cdd27ac5d9628a27faecc40fb66 GIT binary patch literal 77 zcmV-T0J8sh0V^p=O;s>AU@$Z=Ff%bx$gNDv%tB=N-?^8o7KK;!x4hDxZ=ntVWIZ01*pecg literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/objects/b8/2ed4a67bef9ef50807adf409f103ef7b0832ab b/test/integration/forcePushMultiple/expected/.git_keep/objects/b8/2ed4a67bef9ef50807adf409f103ef7b0832ab new file mode 100644 index 0000000000000000000000000000000000000000..55c8270daa81e5e4cdcaa1b2eeeabcb4f7b732e1 GIT binary patch literal 149 zcmV;G0BZku0gaA93c@fD06pgwxeJobrp*RKgr540WV4F}V@rvkzqe2DG%(Czcx`Rz z7E(C%UBvnV5t&A)8W1%HRLvDo$uSiK&%;3$v*lf0-3DKSBUWX06l?YXFlds(K1qt> zkbRLtX!5&1*4<9Cy-xF8KDljAx$xR<7REprT%c&r0M41i9#dWZ%uW01@)R^bRRB9O DRux1N literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/objects/ce/0848710343a75263ea72cb5bdfa666b9ecda68 b/test/integration/forcePushMultiple/expected/.git_keep/objects/ce/0848710343a75263ea72cb5bdfa666b9ecda68 new file mode 100644 index 0000000000000000000000000000000000000000..5e9361d3548aa14bca5d35e0871b31e326387c70 GIT binary patch literal 103 zcmV-t0GR)H0V^p=O;s>7Fl8__FfcPQQOK=K%gjkNWLUcA@n6-{8($(qqj>V2E(CbB zbYDeLV#FZ9^TVh?Y2Ue*s}_Y<^|!pzo^PR!qQr#ZlF88r;s1<|mAy)TaoXZbQtYkQ JApo0YFGO2mGTHzD literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 b/test/integration/forcePushMultiple/expected/.git_keep/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 new file mode 100644 index 0000000000000000000000000000000000000000..d39fa7d2fecf1c45a132dfe3a8758952f3c8d968 GIT binary patch literal 21 ccmb}lpN08nuUO8@`> literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/objects/d3/708eeec2b9d69acbe87862330e844e85f77de1 b/test/integration/forcePushMultiple/expected/.git_keep/objects/d3/708eeec2b9d69acbe87862330e844e85f77de1 new file mode 100644 index 0000000000000000000000000000000000000000..e36f500bdd0daf555f8c0a188d92b5d2cc80531d GIT binary patch literal 149 zcmV;G0BZku0gaAJ3c@fDKwak)*$a|MCO;4ny6Q0|lL;1#EhU29-X6j2b`B2}Ua^bb#Gz3fz&5_k-0AtiakEtPl>Z*U+@)T4*8fiM= D)tx}L literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b b/test/integration/forcePushMultiple/expected/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b new file mode 100644 index 0000000000000000000000000000000000000000..9b771fc2f6f41f91b00976b4ff3f8f9935f7931e GIT binary patch literal 21 ccmb>`CU&08otwO#lD@ literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/refs/heads/master b/test/integration/forcePushMultiple/expected/.git_keep/refs/heads/master new file mode 100644 index 000000000..f9339e7e2 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/refs/heads/master @@ -0,0 +1 @@ +42d408cffcc087da21115f9ebc29e9765a2beb83 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/refs/heads/other_branch b/test/integration/forcePushMultiple/expected/.git_keep/refs/heads/other_branch new file mode 100644 index 000000000..f9339e7e2 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/refs/heads/other_branch @@ -0,0 +1 @@ +42d408cffcc087da21115f9ebc29e9765a2beb83 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/refs/remotes/origin/master b/test/integration/forcePushMultiple/expected/.git_keep/refs/remotes/origin/master new file mode 100644 index 000000000..f9339e7e2 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/refs/remotes/origin/master @@ -0,0 +1 @@ +42d408cffcc087da21115f9ebc29e9765a2beb83 diff --git a/test/integration/forcePushMultiple/expected/.git_keep/refs/remotes/origin/other_branch b/test/integration/forcePushMultiple/expected/.git_keep/refs/remotes/origin/other_branch new file mode 100644 index 000000000..f9339e7e2 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/.git_keep/refs/remotes/origin/other_branch @@ -0,0 +1 @@ +42d408cffcc087da21115f9ebc29e9765a2beb83 diff --git a/test/integration/forcePushMultiple/expected/myfile1 b/test/integration/forcePushMultiple/expected/myfile1 new file mode 100644 index 000000000..a5bce3fd2 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/myfile1 @@ -0,0 +1 @@ +test1 diff --git a/test/integration/forcePushMultiple/expected/myfile2 b/test/integration/forcePushMultiple/expected/myfile2 new file mode 100644 index 000000000..180cf8328 --- /dev/null +++ b/test/integration/forcePushMultiple/expected/myfile2 @@ -0,0 +1 @@ +test2 diff --git a/test/integration/forcePushMultiple/expected_remote/HEAD b/test/integration/forcePushMultiple/expected_remote/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/forcePushMultiple/expected_remote/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/forcePushMultiple/expected_remote/config b/test/integration/forcePushMultiple/expected_remote/config new file mode 100644 index 000000000..c51ded5d7 --- /dev/null +++ b/test/integration/forcePushMultiple/expected_remote/config @@ -0,0 +1,8 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true + ignorecase = true + precomposeunicode = true +[remote "origin"] + url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/forcePushMultiple/./actual diff --git a/test/integration/forcePushMultiple/expected_remote/description b/test/integration/forcePushMultiple/expected_remote/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/forcePushMultiple/expected_remote/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/forcePushMultiple/expected_remote/info/exclude b/test/integration/forcePushMultiple/expected_remote/info/exclude new file mode 100644 index 000000000..8e9f2071f --- /dev/null +++ b/test/integration/forcePushMultiple/expected_remote/info/exclude @@ -0,0 +1,7 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ +.DS_Store diff --git a/test/integration/forcePushMultiple/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 b/test/integration/forcePushMultiple/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 new file mode 100644 index 0000000000000000000000000000000000000000..7f2ebf4eeb6ad6875bcc2a2b91ca3345ee06b45e GIT binary patch literal 52 zcmb`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/forcePushMultiple/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 new file mode 100644 index 0000000000000000000000000000000000000000..96d2e71a6af75cdd27ac5d9628a27faecc40fb66 GIT binary patch literal 77 zcmV-T0J8sh0V^p=O;s>AU@$Z=Ff%bx$gNDv%tB=N-?^8o7KK;!x4hDxZ=ntVWIZ01*pecg literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected_remote/objects/b8/2ed4a67bef9ef50807adf409f103ef7b0832ab b/test/integration/forcePushMultiple/expected_remote/objects/b8/2ed4a67bef9ef50807adf409f103ef7b0832ab new file mode 100644 index 0000000000000000000000000000000000000000..55c8270daa81e5e4cdcaa1b2eeeabcb4f7b732e1 GIT binary patch literal 149 zcmV;G0BZku0gaA93c@fD06pgwxeJobrp*RKgr540WV4F}V@rvkzqe2DG%(Czcx`Rz z7E(C%UBvnV5t&A)8W1%HRLvDo$uSiK&%;3$v*lf0-3DKSBUWX06l?YXFlds(K1qt> zkbRLtX!5&1*4<9Cy-xF8KDljAx$xR<7REprT%c&r0M41i9#dWZ%uW01@)R^bRRB9O DRux1N literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected_remote/objects/ce/0848710343a75263ea72cb5bdfa666b9ecda68 b/test/integration/forcePushMultiple/expected_remote/objects/ce/0848710343a75263ea72cb5bdfa666b9ecda68 new file mode 100644 index 0000000000000000000000000000000000000000..5e9361d3548aa14bca5d35e0871b31e326387c70 GIT binary patch literal 103 zcmV-t0GR)H0V^p=O;s>7Fl8__FfcPQQOK=K%gjkNWLUcA@n6-{8($(qqj>V2E(CbB zbYDeLV#FZ9^TVh?Y2Ue*s}_Y<^|!pzo^PR!qQr#ZlF88r;s1<|mAy)TaoXZbQtYkQ JApo0YFGO2mGTHzD literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected_remote/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 b/test/integration/forcePushMultiple/expected_remote/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 new file mode 100644 index 0000000000000000000000000000000000000000..d39fa7d2fecf1c45a132dfe3a8758952f3c8d968 GIT binary patch literal 21 ccmb}lpN08nuUO8@`> literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected_remote/objects/d3/708eeec2b9d69acbe87862330e844e85f77de1 b/test/integration/forcePushMultiple/expected_remote/objects/d3/708eeec2b9d69acbe87862330e844e85f77de1 new file mode 100644 index 0000000000000000000000000000000000000000..e36f500bdd0daf555f8c0a188d92b5d2cc80531d GIT binary patch literal 149 zcmV;G0BZku0gaAJ3c@fDKwak)*$a|MCO;4ny6Q0|lL;1#EhU29-X6j2b`B2}Ua^bb#Gz3fz&5_k-0AtiakEtPl>Z*U+@)T4*8fiM= D)tx}L literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected_remote/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b b/test/integration/forcePushMultiple/expected_remote/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b new file mode 100644 index 0000000000000000000000000000000000000000..9b771fc2f6f41f91b00976b4ff3f8f9935f7931e GIT binary patch literal 21 ccmb>`CU&08otwO#lD@ literal 0 HcmV?d00001 diff --git a/test/integration/forcePushMultiple/expected_remote/packed-refs b/test/integration/forcePushMultiple/expected_remote/packed-refs new file mode 100644 index 000000000..07ff7e761 --- /dev/null +++ b/test/integration/forcePushMultiple/expected_remote/packed-refs @@ -0,0 +1,3 @@ +# pack-refs with: peeled fully-peeled sorted +42d408cffcc087da21115f9ebc29e9765a2beb83 refs/heads/master +42d408cffcc087da21115f9ebc29e9765a2beb83 refs/heads/other_branch diff --git a/test/integration/forcePushMultiple/expected_remote/refs/heads/master b/test/integration/forcePushMultiple/expected_remote/refs/heads/master new file mode 100644 index 000000000..f9339e7e2 --- /dev/null +++ b/test/integration/forcePushMultiple/expected_remote/refs/heads/master @@ -0,0 +1 @@ +42d408cffcc087da21115f9ebc29e9765a2beb83 diff --git a/test/integration/forcePushMultiple/expected_remote/refs/heads/other_branch b/test/integration/forcePushMultiple/expected_remote/refs/heads/other_branch new file mode 100644 index 000000000..f9339e7e2 --- /dev/null +++ b/test/integration/forcePushMultiple/expected_remote/refs/heads/other_branch @@ -0,0 +1 @@ +42d408cffcc087da21115f9ebc29e9765a2beb83 diff --git a/test/integration/forcePushMultiple/recording.json b/test/integration/forcePushMultiple/recording.json new file mode 100644 index 000000000..dd0070f15 --- /dev/null +++ b/test/integration/forcePushMultiple/recording.json @@ -0,0 +1 @@ +{"KeyEvents":[{"Timestamp":591,"Mod":0,"Key":256,"Ch":80},{"Timestamp":1207,"Mod":0,"Key":13,"Ch":13},{"Timestamp":1990,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/forcePushMultiple/setup.sh b/test/integration/forcePushMultiple/setup.sh new file mode 100644 index 000000000..3c599991f --- /dev/null +++ b/test/integration/forcePushMultiple/setup.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +set -e + +set -e + +cd $1 + +git init + +git config user.email "CI@example.com" +git config user.name "CI" +git config push.default matching + +echo test1 > myfile1 +git add . +git commit -am "myfile1" +echo test2 > myfile2 +git add . +git commit -am "myfile2" + +git checkout -b other_branch +git checkout master + +cd .. +git clone --bare ./actual actual_remote + +cd actual + +git remote add origin ../actual_remote +git fetch origin +git branch --set-upstream-to=origin/master master +git branch --set-upstream-to=origin/other_branch other_branch + +echo test3 > myfile3 +git add . +git commit -am "myfile3" + +git push origin master +git reset --hard HEAD^ + +git checkout other_branch + +echo test4 > myfile4 +git add . +git commit -am "myfile4" + +git push origin other_branch +git reset --hard HEAD^ + +git checkout master + +# at this point, both branches have diverged from their remote counterparts, meaning if you +# attempt to push either, it'll ask if you want to force push. diff --git a/test/integration/forcePushMultiple/test.json b/test/integration/forcePushMultiple/test.json new file mode 100644 index 000000000..f939494e9 --- /dev/null +++ b/test/integration/forcePushMultiple/test.json @@ -0,0 +1,4 @@ +{ + "description": "Force push to multiple branches because the user hasn't configured git to do otherwise", + "speed": 10 +}