Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions pkg/gui/controllers/branches_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ func (self *BranchesController) GetOnRenderToMain() func() {
}

func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branch) error {
upstream := lo.Ternary(selectedBranch.RemoteBranchStoredLocally(),
selectedBranch.ShortUpstreamRefName(),
self.c.Tr.UpstreamGenericName)

viewDivergenceItem := &types.MenuItem{
LabelColumns: []string{self.c.Tr.ViewDivergenceFromUpstream},
OnPress: func() error {
Expand All @@ -204,7 +208,7 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc

return self.c.Helpers().SubCommits.ViewSubCommits(helpers.ViewSubCommitsOpts{
Ref: branch,
TitleRef: fmt.Sprintf("%s <-> %s", branch.RefName(), branch.ShortUpstreamRefName()),
TitleRef: fmt.Sprintf("%s <-> %s", branch.RefName(), upstream),
RefToShowDivergenceFrom: branch.FullUpstreamRefName(),
Context: self.context(),
ShowBranchHeads: false,
Expand Down Expand Up @@ -293,9 +297,6 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
Key: 's',
}

upstream := lo.Ternary(selectedBranch.RemoteBranchStoredLocally(),
fmt.Sprintf("%s/%s", selectedBranch.UpstreamRemote, selectedBranch.Name),
self.c.Tr.UpstreamGenericName)
upstreamResetOptions := utils.ResolvePlaceholderString(
self.c.Tr.ViewUpstreamResetOptions,
map[string]string{"upstream": upstream},
Expand Down Expand Up @@ -332,7 +333,7 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
LabelColumns: []string{upstreamRebaseOptions},
OpensMenu: true,
OnPress: func() error {
if err := self.c.Helpers().MergeAndRebase.RebaseOntoRef(selectedBranch.ShortUpstreamRefName()); err != nil {
if err := self.c.Helpers().MergeAndRebase.RebaseOntoRef(upstream); err != nil {
return err
}
return nil
Expand Down
4 changes: 4 additions & 0 deletions pkg/integration/components/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/integration/tests/branch/rebase_to_upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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() {
Expand All @@ -58,7 +59,7 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Lines(
Contains("target"),
Contains("base-branch"),
Contains("master").IsSelected(),
Contains("master-local").IsSelected(),
).
Press(keys.Branches.SetUpstream).
Tap(func() {
Expand Down
7 changes: 4 additions & 3 deletions pkg/integration/tests/branch/reset_to_upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand All @@ -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).
Expand All @@ -51,7 +52,7 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
SelectNextItem().
Lines(
Contains("base"),
Contains("soft-branch").IsSelected(),
Contains("soft-branch-local").IsSelected(),
Contains("hard-branch"),
).
Press(keys.Branches.SetUpstream).
Expand Down Expand Up @@ -80,7 +81,7 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Focus().
Lines(
Contains("base"),
Contains("soft-branch").IsSelected(),
Contains("soft-branch-local").IsSelected(),
Contains("hard-branch"),
).
NavigateToLine(Contains("hard-branch")).
Expand Down
Loading