Fix resetting or rebasing a branch to its upstream when the upstream branch name is different

This commit is contained in:
Stefan Haller 2025-01-04 15:18:22 +01:00
parent 33e81f717d
commit 009062534e
3 changed files with 1 additions and 18 deletions

View file

@ -294,7 +294,7 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
}
upstream := lo.Ternary(selectedBranch.RemoteBranchStoredLocally(),
fmt.Sprintf("%s/%s", selectedBranch.UpstreamRemote, selectedBranch.Name),
selectedBranch.ShortUpstreamRefName(),
self.c.Tr.UpstreamGenericName)
upstreamResetOptions := utils.ResolvePlaceholderString(
self.c.Tr.ViewUpstreamResetOptions,

View file

@ -65,10 +65,7 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
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'")).

View file

@ -59,27 +59,14 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
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"),
@ -88,7 +75,6 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Contains("file-1").Contains("A"),
Contains("file-2").Contains("A"),
)
*/
// hard reset
t.Views().Branches().