mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-25 22:32:13 +02:00
pkg/gui: Allow user to select remote and branch when creating a PR
When creating a PR against a selected branch (via O = "create pull request options"), the user will first be asked to select a remote (if there is more than one). After that, the suggestion area is populated with all remote branches at that origin - instead of all local ones. After all, creating a PR against a branch that doesn't exist on the remote won't work. Please note that for the "PR is not filed against 'origin' remote" use case (e.g. when contributing via a fork that is 'origin' to a GitHub project that is 'upstream'), the opened URL will not be correct. This is not a regression and will be fixed in an upcoming PR. Fixes #1826.
This commit is contained in:
committed by
Jesse Duffield
parent
b62546c391
commit
949e131ebe
@@ -162,10 +162,26 @@ func (self *SuggestionsHelper) getRemoteBranchNames(separator string) []string {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *SuggestionsHelper) getRemoteBranchNamesForRemote(remoteName string) []string {
|
||||
remote, ok := lo.Find(self.c.Model().Remotes, func(remote *models.Remote) bool {
|
||||
return remote.Name == remoteName
|
||||
})
|
||||
if ok {
|
||||
return lo.Map(remote.Branches, func(branch *models.RemoteBranch, _ int) string {
|
||||
return branch.Name
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SuggestionsHelper) GetRemoteBranchesSuggestionsFunc(separator string) func(string) []*types.Suggestion {
|
||||
return FilterFunc(self.getRemoteBranchNames(separator), self.c.UserConfig().Gui.UseFuzzySearch())
|
||||
}
|
||||
|
||||
func (self *SuggestionsHelper) GetRemoteBranchesForRemoteSuggestionsFunc(remoteName string) func(string) []*types.Suggestion {
|
||||
return FilterFunc(self.getRemoteBranchNamesForRemote(remoteName), self.c.UserConfig().Gui.UseFuzzySearch())
|
||||
}
|
||||
|
||||
func (self *SuggestionsHelper) getTagNames() []string {
|
||||
return lo.Map(self.c.Model().Tags, func(tag *models.Tag, _ int) string {
|
||||
return tag.Name
|
||||
|
||||
Reference in New Issue
Block a user