@@ -443,28 +443,29 @@ func (issue *Issue) PatchURL() string {
443443 return ""
444444}
445445
446- /* the logic should be kept the same as getIssueIcon/getIssueColor in TS code */
446+ // IconHTML returns the HTML for the issue icon.
447+ // the logic should be kept the same as getIssueIcon/getIssueColor in TS code
447448func (issue * Issue ) IconHTML (ctx context.Context ) template.HTML {
448- if issue .IsPull {
449- if issue .PullRequest == nil { // pull request should be loaded before calling this function
450- return template .HTML ("No PullRequest" )
451- }
449+ if ! issue .IsPull {
452450 if issue .IsClosed {
453- if issue .PullRequest .HasMerged {
454- return svg .RenderHTML ("octicon-git-merge" , 16 , "text purple" )
455- }
456- return svg .RenderHTML ("octicon-git-pull-request-closed" , 16 , "text red" )
457- }
458- if issue .PullRequest .IsWorkInProgress (ctx ) {
459- return svg .RenderHTML ("octicon-git-pull-request-draft" , 16 , "text grey" )
451+ return svg .RenderHTML ("octicon-issue-closed" , 16 , "text red" )
460452 }
461- return svg .RenderHTML ("octicon-git-pull-request " , 16 , "text green" )
453+ return svg .RenderHTML ("octicon-issue-opened " , 16 , "text green" )
462454 }
463455
464- if issue .IsClosed {
465- return svg .RenderHTML ("octicon-issue-closed" , 16 , "text red" )
456+ switch {
457+ case issue .PullRequest == nil : // pull request should be loaded before calling this function
458+ return template .HTML ("No PullRequest" )
459+ case issue .IsClosed :
460+ if issue .PullRequest .HasMerged {
461+ return svg .RenderHTML ("octicon-git-merge" , 16 , "text purple" )
462+ }
463+ return svg .RenderHTML ("octicon-git-pull-request-closed" , 16 , "text red" )
464+ case issue .PullRequest .IsWorkInProgress (ctx ):
465+ return svg .RenderHTML ("octicon-git-pull-request-draft" , 16 , "text grey" )
466+ default :
467+ return svg .RenderHTML ("octicon-git-pull-request" , 16 , "text green" )
466468 }
467- return svg .RenderHTML ("octicon-issue-opened" , 16 , "text green" )
468469}
469470
470471// State returns string representation of issue status.
0 commit comments