mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 04:45: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
3 changed files with 30 additions and 7 deletions
|
@ -142,6 +142,10 @@ func (self *Shell) NewBranchFrom(name string, from string) *Shell {
|
||||||
return self.RunCommand([]string{"git", "checkout", "-b", name, from})
|
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 {
|
func (self *Shell) Checkout(name string) *Shell {
|
||||||
return self.RunCommand([]string{"git", "checkout", name})
|
return self.RunCommand([]string{"git", "checkout", name})
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,9 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
EmptyCommit("ensure-master").
|
EmptyCommit("ensure-master").
|
||||||
EmptyCommit("to-be-added"). // <- this will only exist remotely
|
EmptyCommit("to-be-added"). // <- this will only exist remotely
|
||||||
PushBranchAndSetUpstream("origin", "master").
|
PushBranchAndSetUpstream("origin", "master").
|
||||||
|
RenameCurrentBranch("master-local").
|
||||||
HardReset("HEAD~1").
|
HardReset("HEAD~1").
|
||||||
NewBranchFrom("base-branch", "master").
|
NewBranchFrom("base-branch", "master-local").
|
||||||
EmptyCommit("base-branch-commit").
|
EmptyCommit("base-branch-commit").
|
||||||
NewBranch("target").
|
NewBranch("target").
|
||||||
EmptyCommit("target-commit")
|
EmptyCommit("target-commit")
|
||||||
|
@ -34,13 +35,13 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
Lines(
|
Lines(
|
||||||
Contains("target").IsSelected(),
|
Contains("target").IsSelected(),
|
||||||
Contains("base-branch"),
|
Contains("base-branch"),
|
||||||
Contains("master"),
|
Contains("master-local"),
|
||||||
).
|
).
|
||||||
SelectNextItem().
|
SelectNextItem().
|
||||||
Lines(
|
Lines(
|
||||||
Contains("target"),
|
Contains("target"),
|
||||||
Contains("base-branch").IsSelected(),
|
Contains("base-branch").IsSelected(),
|
||||||
Contains("master"),
|
Contains("master-local"),
|
||||||
).
|
).
|
||||||
Press(keys.Branches.SetUpstream).
|
Press(keys.Branches.SetUpstream).
|
||||||
Tap(func() {
|
Tap(func() {
|
||||||
|
@ -58,13 +59,16 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
Lines(
|
Lines(
|
||||||
Contains("target"),
|
Contains("target"),
|
||||||
Contains("base-branch"),
|
Contains("base-branch"),
|
||||||
Contains("master").IsSelected(),
|
Contains("master-local").IsSelected(),
|
||||||
).
|
).
|
||||||
Press(keys.Branches.SetUpstream).
|
Press(keys.Branches.SetUpstream).
|
||||||
Tap(func() {
|
Tap(func() {
|
||||||
t.ExpectPopup().Menu().
|
t.ExpectPopup().Menu().
|
||||||
Title(Equals("Upstream options")).
|
Title(Equals("Upstream options")).
|
||||||
|
/* EXPECTED:
|
||||||
Select(Contains("Rebase checked-out branch onto origin/master...")).
|
Select(Contains("Rebase checked-out branch onto origin/master...")).
|
||||||
|
ACTUAL: */
|
||||||
|
Select(Contains("Rebase checked-out branch onto origin/master-local...")).
|
||||||
Confirm()
|
Confirm()
|
||||||
t.ExpectPopup().Menu().
|
t.ExpectPopup().Menu().
|
||||||
Title(Equals("Rebase 'target'")).
|
Title(Equals("Rebase 'target'")).
|
||||||
|
|
|
@ -19,6 +19,7 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
NewBranch("soft-branch").
|
NewBranch("soft-branch").
|
||||||
EmptyCommit("soft commit").
|
EmptyCommit("soft commit").
|
||||||
PushBranchAndSetUpstream("origin", "soft-branch").
|
PushBranchAndSetUpstream("origin", "soft-branch").
|
||||||
|
RenameCurrentBranch("soft-branch-local").
|
||||||
NewBranch("base").
|
NewBranch("base").
|
||||||
EmptyCommit("base-branch commit").
|
EmptyCommit("base-branch commit").
|
||||||
CreateFile("file-1", "content").
|
CreateFile("file-1", "content").
|
||||||
|
@ -33,7 +34,7 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
Contains("base").IsSelected(),
|
Contains("base").IsSelected(),
|
||||||
Contains("soft-branch"),
|
Contains("soft-branch-local"),
|
||||||
Contains("hard-branch"),
|
Contains("hard-branch"),
|
||||||
).
|
).
|
||||||
Press(keys.Branches.SetUpstream).
|
Press(keys.Branches.SetUpstream).
|
||||||
|
@ -51,21 +52,34 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
SelectNextItem().
|
SelectNextItem().
|
||||||
Lines(
|
Lines(
|
||||||
Contains("base"),
|
Contains("base"),
|
||||||
Contains("soft-branch").IsSelected(),
|
Contains("soft-branch-local").IsSelected(),
|
||||||
Contains("hard-branch"),
|
Contains("hard-branch"),
|
||||||
).
|
).
|
||||||
Press(keys.Branches.SetUpstream).
|
Press(keys.Branches.SetUpstream).
|
||||||
Tap(func() {
|
Tap(func() {
|
||||||
t.ExpectPopup().Menu().
|
t.ExpectPopup().Menu().
|
||||||
Title(Equals("Upstream options")).
|
Title(Equals("Upstream options")).
|
||||||
|
/* EXPECTED:
|
||||||
Select(Contains("Reset checked-out branch onto origin/soft-branch...")).
|
Select(Contains("Reset checked-out branch onto origin/soft-branch...")).
|
||||||
|
ACTUAL: */
|
||||||
|
Select(Contains("Reset checked-out branch onto origin/soft-branch-local...")).
|
||||||
Confirm()
|
Confirm()
|
||||||
|
|
||||||
t.ExpectPopup().Menu().
|
t.ExpectPopup().Menu().
|
||||||
|
/* EXPECTED:
|
||||||
Title(Equals("Reset to origin/soft-branch")).
|
Title(Equals("Reset to origin/soft-branch")).
|
||||||
|
ACTUAL: */
|
||||||
|
Title(Equals("Reset to origin/soft-branch-local")).
|
||||||
Select(Contains("Soft reset")).
|
Select(Contains("Soft reset")).
|
||||||
Confirm()
|
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(
|
t.Views().Commits().Lines(
|
||||||
Contains("soft commit"),
|
Contains("soft commit"),
|
||||||
Contains("hard commit"),
|
Contains("hard commit"),
|
||||||
|
@ -74,13 +88,14 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
Contains("file-1").Contains("A"),
|
Contains("file-1").Contains("A"),
|
||||||
Contains("file-2").Contains("A"),
|
Contains("file-2").Contains("A"),
|
||||||
)
|
)
|
||||||
|
*/
|
||||||
|
|
||||||
// hard reset
|
// hard reset
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
Contains("base"),
|
Contains("base"),
|
||||||
Contains("soft-branch").IsSelected(),
|
Contains("soft-branch-local").IsSelected(),
|
||||||
Contains("hard-branch"),
|
Contains("hard-branch"),
|
||||||
).
|
).
|
||||||
NavigateToLine(Contains("hard-branch")).
|
NavigateToLine(Contains("hard-branch")).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue