Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/gui/controllers/branches_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
Expand Down Expand Up @@ -205,7 +206,8 @@ func (self *BranchesController) GetOnRenderToMain() func() {
ptyTask := types.NewRunPtyTask(cmdObj.GetCmd())
task = ptyTask

if pr, ok := self.c.Model().PullRequestsMap[branch.Name]; ok {
pr, ok := self.c.Model().PullRequestsMap[branch.Name]
if ok && presentation.ShouldShowPrForBranch(pr, branch.Name, self.c.UserConfig()) {
icon := lo.Ternary(icons.IsIconEnabled(), icons.IconForRemoteUrl(pr.Url)+" ", "")
ptyTask.Prefix = style.PrintHyperlink(fmt.Sprintf("%s%s %s %s\n",
icon,
Expand Down
12 changes: 11 additions & 1 deletion pkg/gui/presentation/branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func getBranchDisplayStrings(

var coloredPrIcon string
pr, hasPr := prs[b.Name]
if hasPr {
if hasPr && ShouldShowPrForBranch(pr, b.Name, userConfig) {
var prIcon string
if icons.IsIconEnabled() {
prIcon = icons.IconForRemoteUrl(pr.Url)
Expand Down Expand Up @@ -285,3 +285,13 @@ func prColor(state string) style.TextStyle {
return style.FgDefault
}
}

func ShouldShowPrForBranch(pr *models.GithubPullRequest, branchName string, userConfig *config.UserConfig) bool {
if !lo.Contains(userConfig.Git.MainBranches, branchName) {
return true
}

// For main branches we only want to show the PR if it's open (or draft), on the assumption that a
// closed PR for a main branch is always a mistake.
return pr.State != "CLOSED" && pr.State != "MERGED"
}
Loading