1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-09-16 09:16:26 +02:00

Re-enable 'Unset upstream' option when upstream branch is missing (#3086)

This commit is contained in:
Jesse Duffield
2023-12-06 15:58:11 +11:00
committed by GitHub
4 changed files with 64 additions and 38 deletions

View File

@@ -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
}

View File

@@ -1,36 +0,0 @@
package branch
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ResetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Reset the upstream of a branch",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
},
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
Lines(
Contains("master").Contains("origin master").IsSelected(),
).
Press(keys.Branches.SetUpstream).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Upstream options")).
Select(Contains("Unset upstream of selected branch")).
Confirm()
}).
Lines(
Contains("master").DoesNotContain("origin master").IsSelected(),
)
},
})

View File

@@ -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"),
)
},
})

View File

@@ -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,