diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index 03184d57b..5f8285b66 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -440,7 +440,7 @@ func (self *BranchesController) press(selectedBranch *models.Branch) error { } func (self *BranchesController) push(branch *models.Branch) error { - return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(branch, func(upstream string) error { + return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(branch, true, func(upstream string) error { upstreamRemote, upstreamBranch, err := self.c.Helpers().Upstream.ParseUpstream(upstream) if err != nil { return err diff --git a/pkg/gui/controllers/helpers/upstream_helper.go b/pkg/gui/controllers/helpers/upstream_helper.go index 1140d5a2f..61f408d2c 100644 --- a/pkg/gui/controllers/helpers/upstream_helper.go +++ b/pkg/gui/controllers/helpers/upstream_helper.go @@ -37,9 +37,14 @@ func (self *UpstreamHelper) ParseUpstream(upstream string) (string, string, erro return upstreamRemote, upstreamBranch, nil } -func (self *UpstreamHelper) promptForUpstream(initialContent string, onConfirm func(string) error) error { +func (self *UpstreamHelper) promptForUpstream(initialContent string, isPush bool, onConfirm func(string) error) error { + title := self.c.Tr.EnterUpstream + if isPush { + title = self.c.Tr.EnterUpstreamNewBranch + } + self.c.Prompt(types.PromptOpts{ - Title: self.c.Tr.EnterUpstream, + Title: title, InitialContent: initialContent, FindSuggestionsFunc: self.getRemoteBranchesSuggestionsFunc(" "), HandleConfirm: onConfirm, @@ -48,17 +53,17 @@ func (self *UpstreamHelper) promptForUpstream(initialContent string, onConfirm f return nil } -func (self *UpstreamHelper) PromptForUpstreamWithInitialContent(currentBranch *models.Branch, onConfirm func(string) error) error { +func (self *UpstreamHelper) PromptForUpstreamWithInitialContent(currentBranch *models.Branch, isPush bool, onConfirm func(string) error) error { initialContent := currentBranch.UpstreamRemote + " " + currentBranch.UpstreamBranch if !currentBranch.IsTrackingRemote() { initialContent = self.GetSuggestedRemote() + " " + currentBranch.Name } - return self.promptForUpstream(initialContent, onConfirm) + return self.promptForUpstream(initialContent, isPush, onConfirm) } func (self *UpstreamHelper) PromptForUpstreamWithoutInitialContent(_ *models.Branch, onConfirm func(string) error) error { - return self.promptForUpstream("", onConfirm) + return self.promptForUpstream("", false, onConfirm) } func (self *UpstreamHelper) GetSuggestedRemote() string { diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index 5b55d1048..e484bcc5d 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -126,7 +126,7 @@ func (self *SyncController) push(currentBranch *models.Branch) error { return self.pushAux(currentBranch, pushOpts{setUpstream: true}) } - return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(currentBranch, func(upstream string) error { + return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(currentBranch, true, func(upstream string) error { upstreamRemote, upstreamBranch, err := self.c.Helpers().Upstream.ParseUpstream(upstream) if err != nil { return err @@ -145,7 +145,7 @@ func (self *SyncController) pull(currentBranch *models.Branch) error { // if we have no upstream branch we need to set that first if !currentBranch.IsTrackingRemote() { - return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(currentBranch, func(upstream string) error { + return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(currentBranch, false, func(upstream string) error { if err := self.setCurrentBranchUpstream(upstream); err != nil { return err } @@ -178,7 +178,7 @@ func (self *SyncController) PullBranch(branch *models.Branch, worktree *models.W } if !branch.IsTrackingRemote() { - return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(branch, func(upstream string) error { + return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(branch, false, func(upstream string) error { upstreamRemote, upstreamBranch, err := self.c.Helpers().Upstream.ParseUpstream(upstream) if err != nil { return err diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 330ee450c..6db747e87 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -559,6 +559,7 @@ type TranslationSet struct { ExitCustomPatchBuilder string ExitFocusedMainView string EnterUpstream string + EnterUpstreamNewBranch string InvalidUpstream string NewRemote string NewRemoteName string @@ -1731,6 +1732,7 @@ func EnglishTranslationSet() *TranslationSet { ExitCustomPatchBuilder: `Exit custom patch builder`, ExitFocusedMainView: "Exit back to side panel", EnterUpstream: `Enter upstream as ' '`, + EnterUpstreamNewBranch: `Enter upstream as ' ' — new upstream branch will be created`, InvalidUpstream: "Invalid upstream. Must be in the format ' '", NewRemote: `New remote`, NewRemoteName: `New remote name:`,