mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
There's gotta be a better way for initial content
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user