@@ -3,12 +3,14 @@ package controllers
33import (
44 "errors"
55 "fmt"
6+ "strconv"
67
78 "github.com/jesseduffield/gocui"
89 "github.com/jesseduffield/lazygit/pkg/commands/git_commands"
910 "github.com/jesseduffield/lazygit/pkg/commands/models"
1011 "github.com/jesseduffield/lazygit/pkg/gui/context"
1112 "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
13+ "github.com/jesseduffield/lazygit/pkg/gui/style"
1214 "github.com/jesseduffield/lazygit/pkg/gui/types"
1315 "github.com/jesseduffield/lazygit/pkg/utils"
1416 "github.com/samber/lo"
@@ -192,7 +194,23 @@ func (self *BranchesController) GetOnRenderToMain() func() {
192194 } else {
193195 cmdObj := self .c .Git ().Branch .GetGraphCmdObj (branch .FullRefName ())
194196
195- task = types .NewRunPtyTask (cmdObj .GetCmd ())
197+ ptyTask := types .NewRunPtyTask (cmdObj .GetCmd ())
198+ task = ptyTask
199+
200+ // Shouldn't we hold on to the map for longer instead of generating it every time?
201+ // It is also generated every time we render the branches list.
202+ prs := git_commands .GenerateGithubPullRequestMap (
203+ self .c .Model ().PullRequests ,
204+ self .c .Model ().Branches ,
205+ self .c .Model ().Remotes ,
206+ )
207+
208+ if pr , ok := prs [branch .Name ]; ok {
209+ ptyTask .Prefix = fmt .Sprintf ("%s %s (%s)\n \n " ,
210+ coloredPrNumber (pr ),
211+ style .FgYellow .Sprint (style .PrintHyperlink (pr .Title , pr .Url )),
212+ pr .State )
213+ }
196214 }
197215
198216 self .c .RenderToMainViews (types.RefreshMainOpts {
@@ -206,6 +224,23 @@ func (self *BranchesController) GetOnRenderToMain() func() {
206224 }
207225}
208226
227+ func coloredPrNumber (pr * models.GithubPullRequest ) string {
228+ return prColor (pr .State ).Sprint ("#" + strconv .Itoa (pr .Number ))
229+ }
230+
231+ func prColor (state string ) style.TextStyle {
232+ switch state {
233+ case "OPEN" :
234+ return style .FgGreen
235+ case "CLOSED" :
236+ return style .FgRed
237+ case "MERGED" :
238+ return style .FgMagenta
239+ default :
240+ return style .FgDefault
241+ }
242+ }
243+
209244func (self * BranchesController ) viewUpstreamOptions (selectedBranch * models.Branch ) error {
210245 upstream := lo .Ternary (selectedBranch .RemoteBranchStoredLocally (),
211246 selectedBranch .ShortUpstreamRefName (),
0 commit comments