1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-17 00:18:05 +02:00

Correctly request force-pushing in triangular workflows

To determine whether we need to ask for force pushing, we need to query the push
branch rather than the upstream branch, in case they are not the same.
This commit is contained in:
Stefan Haller
2024-04-26 11:20:16 +02:00
parent d890c68cd0
commit c5cf1b2428
3 changed files with 5 additions and 8 deletions

View File

@ -103,6 +103,10 @@ func (b *Branch) IsBehindForPull() bool {
return b.RemoteBranchStoredLocally() && b.BehindForPull != "0"
}
func (b *Branch) IsBehindForPush() bool {
return b.BehindForPush != "" && b.BehindForPush != "0"
}
// for when we're in a detached head state
func (b *Branch) IsRealBranch() bool {
return b.AheadForPull != "" && b.BehindForPull != ""

View File

@ -90,7 +90,7 @@ func (self *SyncController) push(currentBranch *models.Branch) error {
// if we are behind our upstream branch we'll ask if the user wants to force push
if currentBranch.IsTrackingRemote() {
opts := pushOpts{}
if currentBranch.IsBehindForPull() {
if currentBranch.IsBehindForPush() {
return self.requestToForcePush(currentBranch, opts)
} else {
return self.pushAux(currentBranch, opts)

View File

@ -36,12 +36,6 @@ var ForcePushTriangular = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Files().IsFocused().Press(keys.Universal.Push)
// This results in an attempt to push normally, which fails with an error:
t.ExpectPopup().Alert().
Title(Equals("Error")).
Content(Contains("Updates were rejected. Please fetch and examine the remote changes before pushing again."))
/* EXPECTED:
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.")).
@ -67,6 +61,5 @@ var ForcePushTriangular = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().SubCommits().IsFocused().
Lines(Contains("one"))
*/
},
})