Skip to content

Commit

Permalink
Re-enable 'Unset upstream' option when upstream branch is missing (#3086
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jesseduffield authored Dec 6, 2023
2 parents f40f571 + d145e81 commit 2162e5f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 38 deletions.
5 changes: 4 additions & 1 deletion pkg/gui/controllers/branches_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,12 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
Key: 'r',
}

if !selectedBranch.IsTrackingRemote() {
unsetUpstreamItem.DisabledReason = self.c.Tr.UpstreamNotSetError
}

if !selectedBranch.RemoteBranchStoredLocally() {
viewDivergenceItem.DisabledReason = self.c.Tr.UpstreamNotSetError
unsetUpstreamItem.DisabledReason = self.c.Tr.UpstreamNotSetError
upstreamResetItem.DisabledReason = self.c.Tr.UpstreamNotSetError
upstreamRebaseItem.DisabledReason = self.c.Tr.UpstreamNotSetError
}
Expand Down
36 changes: 0 additions & 36 deletions pkg/integration/tests/branch/reset_upstream.go

This file was deleted.

59 changes: 59 additions & 0 deletions pkg/integration/tests/branch/unset_upstream.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package branch

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var UnsetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Unset upstream of selected branch, both when it exists and when it doesn't",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
EmptyCommit("one").
NewBranch("branch_to_remove").
Checkout("master").
CloneIntoRemote("origin").
SetBranchUpstream("master", "origin/master").
SetBranchUpstream("branch_to_remove", "origin/branch_to_remove").
// to get the "(upstream gone)" branch status
RunCommand([]string{"git", "push", "origin", "--delete", "branch_to_remove"})
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Press(keys.Universal.NextScreenMode). // we need to enlargen the window to see the upstream
SelectedLines(
Contains("master").Contains("origin master"),
).
Press(keys.Branches.SetUpstream).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Upstream options")).
Select(Contains("Unset upstream of selected branch")).
Confirm()
}).
SelectedLines(
Contains("master").DoesNotContain("origin master"),
)

t.Views().Branches().
Focus().
SelectNextItem().
SelectedLines(
Contains("branch_to_remove").Contains("origin branch_to_remove").Contains("upstream gone"),
).
Press(keys.Branches.SetUpstream).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Upstream options")).
Select(Contains("Unset upstream of selected branch")).
Confirm()
}).
SelectedLines(
Contains("branch_to_remove").DoesNotContain("origin branch_to_remove").DoesNotContain("upstream gone"),
)
},
})
2 changes: 1 addition & 1 deletion pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ var tests = []*components.IntegrationTest{
branch.Rename,
branch.Reset,
branch.ResetToUpstream,
branch.ResetUpstream,
branch.SetUpstream,
branch.ShowDivergenceFromUpstream,
branch.Suggestions,
branch.UnsetUpstream,
cherry_pick.CherryPick,
cherry_pick.CherryPickConflicts,
cherry_pick.CherryPickDuringRebase,
Expand Down

0 comments on commit 2162e5f

Please sign in to comment.