mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-25 12:24:47 +02:00
Extend reset/rebase test to use upstream branch name that is different from local one
The easiest way to do that is to rename the local branch after pushing. This shows various levels of brokenness for the reset and rebase to upstream commands: both menu entries display the wrong upstream branch name in the menu (the local one rather than the remote one); executing the rebase command works correctly though, the rebase command uses the right branch name. Resetting fails, though. We'll fix this in the next commit.
This commit is contained in:
parent
ef718f3386
commit
33e81f717d
@ -142,6 +142,10 @@ func (self *Shell) NewBranchFrom(name string, from string) *Shell {
|
||||
return self.RunCommand([]string{"git", "checkout", "-b", name, from})
|
||||
}
|
||||
|
||||
func (self *Shell) RenameCurrentBranch(newName string) *Shell {
|
||||
return self.RunCommand([]string{"git", "branch", "-m", newName})
|
||||
}
|
||||
|
||||
func (self *Shell) Checkout(name string) *Shell {
|
||||
return self.RunCommand([]string{"git", "checkout", name})
|
||||
}
|
||||
|
@ -16,8 +16,9 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
EmptyCommit("ensure-master").
|
||||
EmptyCommit("to-be-added"). // <- this will only exist remotely
|
||||
PushBranchAndSetUpstream("origin", "master").
|
||||
RenameCurrentBranch("master-local").
|
||||
HardReset("HEAD~1").
|
||||
NewBranchFrom("base-branch", "master").
|
||||
NewBranchFrom("base-branch", "master-local").
|
||||
EmptyCommit("base-branch-commit").
|
||||
NewBranch("target").
|
||||
EmptyCommit("target-commit")
|
||||
@ -34,13 +35,13 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Lines(
|
||||
Contains("target").IsSelected(),
|
||||
Contains("base-branch"),
|
||||
Contains("master"),
|
||||
Contains("master-local"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Lines(
|
||||
Contains("target"),
|
||||
Contains("base-branch").IsSelected(),
|
||||
Contains("master"),
|
||||
Contains("master-local"),
|
||||
).
|
||||
Press(keys.Branches.SetUpstream).
|
||||
Tap(func() {
|
||||
@ -58,13 +59,16 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Lines(
|
||||
Contains("target"),
|
||||
Contains("base-branch"),
|
||||
Contains("master").IsSelected(),
|
||||
Contains("master-local").IsSelected(),
|
||||
).
|
||||
Press(keys.Branches.SetUpstream).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Upstream options")).
|
||||
/* EXPECTED:
|
||||
Select(Contains("Rebase checked-out branch onto origin/master...")).
|
||||
ACTUAL: */
|
||||
Select(Contains("Rebase checked-out branch onto origin/master-local...")).
|
||||
Confirm()
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Rebase 'target'")).
|
||||
|
@ -19,6 +19,7 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
NewBranch("soft-branch").
|
||||
EmptyCommit("soft commit").
|
||||
PushBranchAndSetUpstream("origin", "soft-branch").
|
||||
RenameCurrentBranch("soft-branch-local").
|
||||
NewBranch("base").
|
||||
EmptyCommit("base-branch commit").
|
||||
CreateFile("file-1", "content").
|
||||
@ -33,7 +34,7 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("base").IsSelected(),
|
||||
Contains("soft-branch"),
|
||||
Contains("soft-branch-local"),
|
||||
Contains("hard-branch"),
|
||||
).
|
||||
Press(keys.Branches.SetUpstream).
|
||||
@ -51,21 +52,34 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
Lines(
|
||||
Contains("base"),
|
||||
Contains("soft-branch").IsSelected(),
|
||||
Contains("soft-branch-local").IsSelected(),
|
||||
Contains("hard-branch"),
|
||||
).
|
||||
Press(keys.Branches.SetUpstream).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Upstream options")).
|
||||
/* EXPECTED:
|
||||
Select(Contains("Reset checked-out branch onto origin/soft-branch...")).
|
||||
ACTUAL: */
|
||||
Select(Contains("Reset checked-out branch onto origin/soft-branch-local...")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
/* EXPECTED:
|
||||
Title(Equals("Reset to origin/soft-branch")).
|
||||
ACTUAL: */
|
||||
Title(Equals("Reset to origin/soft-branch-local")).
|
||||
Select(Contains("Soft reset")).
|
||||
Confirm()
|
||||
|
||||
// Bug: the command fails
|
||||
t.ExpectPopup().Alert().
|
||||
Title(Equals("Error")).
|
||||
Content(Contains("fatal: ambiguous argument 'origin/soft-branch-local': unknown revision or path not in the working tree.")).
|
||||
Confirm()
|
||||
})
|
||||
/* Since the command failed, the following assertions are not valid
|
||||
t.Views().Commits().Lines(
|
||||
Contains("soft commit"),
|
||||
Contains("hard commit"),
|
||||
@ -74,13 +88,14 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("file-1").Contains("A"),
|
||||
Contains("file-2").Contains("A"),
|
||||
)
|
||||
*/
|
||||
|
||||
// hard reset
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("base"),
|
||||
Contains("soft-branch").IsSelected(),
|
||||
Contains("soft-branch-local").IsSelected(),
|
||||
Contains("hard-branch"),
|
||||
).
|
||||
NavigateToLine(Contains("hard-branch")).
|
||||
|
Loading…
x
Reference in New Issue
Block a user