diff --git a/pkg/commands/github.go b/pkg/commands/github.go index 823624cf5..dca4fb34d 100644 --- a/pkg/commands/github.go +++ b/pkg/commands/github.go @@ -21,20 +21,18 @@ func (c *GitCommand) GithubMostRecentPRs() ([]*models.GithubPullRequest, error) return prs, nil } -func (c *GitCommand) GenerateGithubPullRequestMap(prs []*models.GithubPullRequest, branches []*models.Branch) (map[*models.Branch]*models.GithubPullRequest, bool) { +func (c *GitCommand) GenerateGithubPullRequestMap(prs []*models.GithubPullRequest, branches []*models.Branch) map[*models.Branch]*models.GithubPullRequest { res := map[*models.Branch]*models.GithubPullRequest{} if len(prs) == 0 { - return res, false + return res } remotesToOwnersMap, _ := c.GetRemotesToOwnersMap() if len(remotesToOwnersMap) == 0 { - return res, false + return res } - foundBranchWithGithubPullRequest := false - prWithStringKey := map[string]models.GithubPullRequest{} for _, pr := range prs { @@ -56,10 +54,8 @@ func (c *GitCommand) GenerateGithubPullRequestMap(prs []*models.GithubPullReques continue } - foundBranchWithGithubPullRequest = true - res[branch] = &pr } - return res, foundBranchWithGithubPullRequest + return res } diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 4b9a8b573..01368704f 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -67,8 +67,6 @@ func (gui *Gui) refreshBranches() { _ = gui.surfaceError(err) } gui.State.Branches = builder.Build() - _, branchesWithGithubPullRequests := builder.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, gui.State.Branches) - gui.State.BranchesWithGithubPullRequests = branchesWithGithubPullRequests if err := gui.postRefreshUpdate(gui.State.Contexts.Branches); err != nil { gui.Log.Error(err) diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 81423b0fe..c9dd5169a 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -74,9 +74,6 @@ func (gui *Gui) refreshReflogCommitsConsideringStartup() { // The github cli can be quite slow so we load the github PRs sparately gui.refreshGithubPullRequests() wg.Wait() - _, branchesWithGithubPullRequests := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, gui.State.Branches) - gui.State.BranchesWithGithubPullRequests = branchesWithGithubPullRequests - _ = gui.postRefreshUpdate(gui.State.Contexts.Branches) }) case COMPLETE: diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index ba8af1108..4d62e08c1 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -287,14 +287,13 @@ type guiMutexes struct { type guiState struct { // the file panels (files and commit files) can render as a tree, so we have // managers for them which handle rendering a flat list of files in tree form - FileManager *filetree.FileManager - CommitFileManager *filetree.CommitFileManager - Submodules []*models.SubmoduleConfig - Branches []*models.Branch - GithubRecentPRs []*models.GithubPullRequest - BranchesWithGithubPullRequests bool - Commits []*models.Commit - StashEntries []*models.StashEntry + FileManager *filetree.FileManager + CommitFileManager *filetree.CommitFileManager + Submodules []*models.SubmoduleConfig + Branches []*models.Branch + GithubRecentPRs []*models.GithubPullRequest + Commits []*models.Commit + StashEntries []*models.StashEntry // Suggestions will sometimes appear when typing into a prompt Suggestions []*types.Suggestion // FilteredReflogCommits are the ones that appear in the reflog panel. @@ -733,7 +732,7 @@ func (gui *Gui) setColorScheme() error { } func (gui *Gui) GetPr(branch *models.Branch) (*models.GithubPullRequest, bool) { - prs, _ := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, []*models.Branch{branch}) + prs := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, []*models.Branch{branch}) pr, hasPr := prs[branch] return pr, hasPr diff --git a/pkg/gui/list_context_config.go b/pkg/gui/list_context_config.go index 0361655ce..90a54cfa4 100644 --- a/pkg/gui/list_context_config.go +++ b/pkg/gui/list_context_config.go @@ -66,15 +66,13 @@ func (gui *Gui) branchesListContext() *ListContext { OnFocus: gui.handleBranchSelect, Gui: gui, GetDisplayStrings: func() [][]string { - prs, branchesWithGithubPullRequests := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, gui.State.Branches) - gui.State.BranchesWithGithubPullRequests = branchesWithGithubPullRequests + prs := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, gui.State.Branches) return presentation.GetBranchListDisplayStrings( gui.State.Branches, prs, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Modes.Diffing.Ref, - gui.State.BranchesWithGithubPullRequests, ) }, SelectedItem: func() (ListItem, bool) { diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go index 6b02fc135..45f31c7c4 100644 --- a/pkg/gui/presentation/branches.go +++ b/pkg/gui/presentation/branches.go @@ -14,13 +14,12 @@ func GetBranchListDisplayStrings( branches []*models.Branch, prs map[*models.Branch]*models.GithubPullRequest, fullDescription bool, - diffName string, - showGithub bool) [][]string { + diffName string) [][]string { lines := make([][]string, len(branches)) for i := range branches { diffed := branches[i].Name == diffName - lines[i] = getBranchDisplayStrings(branches[i], prs, fullDescription, diffed, showGithub) + lines[i] = getBranchDisplayStrings(branches[i], prs, fullDescription, diffed) } return lines @@ -31,8 +30,7 @@ func getBranchDisplayStrings( b *models.Branch, prs map[*models.Branch]*models.GithubPullRequest, fullDescription bool, - diffed, - showGithub bool) []string { + diffed bool) []string { displayName := b.Name if b.DisplayName != "" { displayName = b.DisplayName @@ -53,10 +51,8 @@ func getBranchDisplayStrings( } res := []string{recencyColor.Sprint(b.Recency), coloredName} - if showGithub { - pr, hasPr := prs[b] - res = append(res, coloredPrNumber(pr, hasPr)) - } + pr, hasPr := prs[b] + res = append(res, coloredPrNumber(pr, hasPr)) if fullDescription { return append(res, style.FgYellow.Sprint(b.UpstreamName)) @@ -107,5 +103,5 @@ func coloredPrNumber(pr *models.GithubPullRequest, hasPr bool) string { return colour.Sprint("#" + strconv.Itoa(pr.Number)) } - return "" + return ("") }