feat: add attemptLabel to RenderRunHeader

This commit is contained in:
Wing-Kam Wong 2023-03-26 14:38:24 +08:00
parent 343e730016
commit baaa5c3184

View file

@ -7,14 +7,21 @@ import (
"github.com/cli/cli/v2/pkg/iostreams"
)
func RenderRunHeader(cs *iostreams.ColorScheme, run Run, ago, prNumber string) string {
func RenderRunHeader(cs *iostreams.ColorScheme, run Run, ago, prNumber string, attempt uint64) string {
title := fmt.Sprintf("%s %s%s",
cs.Bold(run.HeadBranch), run.WorkflowName(), prNumber)
symbol, symbolColor := Symbol(cs, run.Status, run.Conclusion)
id := cs.Cyanf("%d", run.ID)
var attemptLabel string
if attempt == 0 {
attemptLabel = "Latest Attempt"
} else {
attemptLabel = fmt.Sprintf("Attempt #%d", attempt)
}
header := ""
header += fmt.Sprintf("%s %s · %s\n", symbolColor(symbol), title, id)
header += fmt.Sprintf("%s %s · %s (%s)\n", symbolColor(symbol), title, id, attemptLabel)
header += fmt.Sprintf("Triggered via %s %s", run.Event, ago)
return header