2023-02-22 21:57:32 +11:00
|
|
|
package branch
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
|
|
)
|
|
|
|
|
2023-10-22 12:00:22 +02:00
|
|
|
var UnsetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
2023-11-04 23:19:38 +01:00
|
|
|
Description: "Unset upstream of selected branch, both when it exists and when it doesn't",
|
2023-05-21 17:00:29 +10:00
|
|
|
ExtraCmdArgs: []string{},
|
2023-02-22 21:57:32 +11:00
|
|
|
Skip: false,
|
|
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
|
|
SetupRepo: func(shell *Shell) {
|
2023-11-04 23:19:38 +01:00
|
|
|
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"})
|
2023-02-22 21:57:32 +11:00
|
|
|
},
|
|
|
|
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
|
2023-11-04 23:19:38 +01:00
|
|
|
SelectedLines(
|
|
|
|
Contains("master").Contains("origin master"),
|
2023-02-22 21:57:32 +11:00
|
|
|
).
|
|
|
|
Press(keys.Branches.SetUpstream).
|
|
|
|
Tap(func() {
|
|
|
|
t.ExpectPopup().Menu().
|
2023-08-27 14:02:13 +02:00
|
|
|
Title(Equals("Upstream options")).
|
2023-05-25 21:11:51 +10:00
|
|
|
Select(Contains("Unset upstream of selected branch")).
|
2023-02-22 21:57:32 +11:00
|
|
|
Confirm()
|
|
|
|
}).
|
2023-11-04 23:19:38 +01:00
|
|
|
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(
|
2023-11-04 17:48:31 +01:00
|
|
|
Contains("branch_to_remove").DoesNotContain("origin branch_to_remove").DoesNotContain("upstream gone"),
|
2023-02-22 21:57:32 +11:00
|
|
|
)
|
|
|
|
},
|
|
|
|
})
|