mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-11 16:16:28 -04:00
refactor logic
This commit is contained in:
parent
769a6cd069
commit
b36f6db521
|
|
@ -101,9 +101,7 @@ func (gui *Gui) handleBranchPress() error {
|
|||
|
||||
func (gui *Gui) handleCreateOrShowPullRequestPress() error {
|
||||
branch := gui.getSelectedBranch()
|
||||
|
||||
prs, _ := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, []*models.Branch{branch})
|
||||
pr, hasPr := prs[branch]
|
||||
pr, hasPr := gui.GetPr(branch)
|
||||
|
||||
if hasPr {
|
||||
return gui.OSCommand.OpenLink(pr.Url)
|
||||
|
|
|
|||
|
|
@ -731,3 +731,10 @@ func (gui *Gui) setColorScheme() error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gui *Gui) GetPr(branch *models.Branch) (*models.GithubPullRequest, bool) {
|
||||
prs, _ := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, []*models.Branch{branch})
|
||||
pr, hasPr := prs[branch]
|
||||
|
||||
return pr, hasPr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,12 +39,11 @@ func (gui *Gui) createOrOpenPullRequestMenu(selectedBranch *models.Branch, check
|
|||
}
|
||||
}
|
||||
|
||||
prs, _ := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, []*models.Branch{selectedBranch})
|
||||
pr, hasPr := prs[selectedBranch]
|
||||
pr, hasPr := gui.GetPr(selectedBranch)
|
||||
|
||||
if hasPr {
|
||||
menuItems = append(menuItems, &menuItem{
|
||||
displayString: gui.GitCommand.Tr.OpenPr + strconv.Itoa(pr.Number),
|
||||
displayString: gui.GitCommand.Tr.MustSpecifyOriginError + strconv.Itoa(pr.Number),
|
||||
onPress: func() error {
|
||||
return gui.OSCommand.OpenLink(pr.Url)
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue