summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/helpers
diff options
context:
space:
mode:
authorLuka Markušić <luka.markusic@microblink.com>2022-04-13 15:21:01 +0200
committerLuka Markušić <luka.markusic@microblink.com>2022-04-13 15:21:01 +0200
commitc4b958e3fddc0b50900def5b32f9ff4246d22a5d (patch)
treeb7a007095dd20b75bc29bef98ad7eb7c9ce69bdd /pkg/gui/controllers/helpers
parentf83308c8df529e5a50332ff68a7e7c5106cea414 (diff)
There's gotta be a better way for initial content
Diffstat (limited to 'pkg/gui/controllers/helpers')
-rw-r--r--pkg/gui/controllers/helpers/upstream_helper.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/pkg/gui/controllers/helpers/upstream_helper.go b/pkg/gui/controllers/helpers/upstream_helper.go
index a0307a9d4..a3ece704e 100644
--- a/pkg/gui/controllers/helpers/upstream_helper.go
+++ b/pkg/gui/controllers/helpers/upstream_helper.go
@@ -17,7 +17,8 @@ type UpstreamHelper struct {
type IUpstreamHelper interface {
ParseUpstream(string) (string, string, error)
- PromptForUpstream(*models.Branch, func(string) error) error
+ PromptForUpstreamWithInitialContent(*models.Branch, func(string) error) error
+ PromptForUpstreamWithoutInitialContent(*models.Branch, func(string) error) error
GetSuggestedRemote() string
}
@@ -48,17 +49,26 @@ func (self *UpstreamHelper) ParseUpstream(upstream string) (string, string, erro
return upstreamRemote, upstreamBranch, nil
}
-func (self *UpstreamHelper) PromptForUpstream(currentBranch *models.Branch, onConfirm func(string) error) error {
- suggestedRemote := self.GetSuggestedRemote()
-
+func (self *UpstreamHelper) promptForUpstream(currentBranch *models.Branch, initialContent string, onConfirm func(string) error) error {
return self.c.Prompt(types.PromptOpts{
Title: self.c.Tr.EnterUpstream,
- InitialContent: suggestedRemote + " " + currentBranch.Name,
+ InitialContent: initialContent,
FindSuggestionsFunc: self.getRemoteBranchesSuggestionsFunc(" "),
HandleConfirm: onConfirm,
})
}
+func (self *UpstreamHelper) PromptForUpstreamWithInitialContent(currentBranch *models.Branch, onConfirm func(string) error) error {
+ suggestedRemote := self.GetSuggestedRemote()
+ initialContent := suggestedRemote + " " + currentBranch.Name
+
+ return self.promptForUpstream(currentBranch, initialContent, onConfirm)
+}
+
+func (self *UpstreamHelper) PromptForUpstreamWithoutInitialContent(currentBranch *models.Branch, onConfirm func(string) error) error {
+ return self.promptForUpstream(currentBranch, "", onConfirm)
+}
+
func (self *UpstreamHelper) GetSuggestedRemote() string {
return getSuggestedRemote(self.model.Remotes)
}