Merge branch 'trunk' into refactor-sigstore-verifier-logic
This commit is contained in:
commit
a3bfb158e4
40 changed files with 460 additions and 222 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -91,14 +92,16 @@ func Test_listRun(t *testing.T) {
|
|||
return cfg
|
||||
}(),
|
||||
input: &ListOptions{Hostname: "HOST"},
|
||||
stdout: `git_protocol=ssh
|
||||
editor=/usr/bin/vim
|
||||
prompt=disabled
|
||||
prefer_editor_prompt=enabled
|
||||
pager=less
|
||||
http_unix_socket=
|
||||
browser=brave
|
||||
`,
|
||||
stdout: heredoc.Doc(`
|
||||
git_protocol=ssh
|
||||
editor=/usr/bin/vim
|
||||
prompt=disabled
|
||||
prefer_editor_prompt=enabled
|
||||
pager=less
|
||||
http_unix_socket=
|
||||
browser=brave
|
||||
color_labels=disabled
|
||||
`),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -293,6 +293,17 @@ func ioStreams(f *cmdutil.Factory) *iostreams.IOStreams {
|
|||
io.SetPager(pager.Value)
|
||||
}
|
||||
|
||||
if ghColorLabels, ghColorLabelsExists := os.LookupEnv("GH_COLOR_LABELS"); ghColorLabelsExists {
|
||||
switch ghColorLabels {
|
||||
case "", "0", "false", "no":
|
||||
io.SetColorLabels(false)
|
||||
default:
|
||||
io.SetColorLabels(true)
|
||||
}
|
||||
} else if prompt := cfg.ColorLabels(""); prompt.Value == "enabled" {
|
||||
io.SetColorLabels(true)
|
||||
}
|
||||
|
||||
io.SetAccessibleColorsEnabled(xcolor.IsAccessibleColorsEnabled())
|
||||
|
||||
return io
|
||||
|
|
|
|||
|
|
@ -432,6 +432,84 @@ func Test_ioStreams_prompt(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func Test_ioStreams_colorLabels(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config gh.Config
|
||||
colorLabelsEnabled bool
|
||||
env map[string]string
|
||||
}{
|
||||
{
|
||||
name: "default config",
|
||||
colorLabelsEnabled: false,
|
||||
},
|
||||
{
|
||||
name: "config with colorLabels enabled",
|
||||
config: enableColorLabelsConfig(),
|
||||
colorLabelsEnabled: true,
|
||||
},
|
||||
{
|
||||
name: "config with colorLabels disabled",
|
||||
config: disableColorLabelsConfig(),
|
||||
colorLabelsEnabled: false,
|
||||
},
|
||||
{
|
||||
name: "colorLabels enabled via `1` in GH_COLOR_LABELS env var",
|
||||
env: map[string]string{"GH_COLOR_LABELS": "1"},
|
||||
colorLabelsEnabled: true,
|
||||
},
|
||||
{
|
||||
name: "colorLabels enabled via `true` in GH_COLOR_LABELS env var",
|
||||
env: map[string]string{"GH_COLOR_LABELS": "true"},
|
||||
colorLabelsEnabled: true,
|
||||
},
|
||||
{
|
||||
name: "colorLabels enabled via `yes` in GH_COLOR_LABELS env var",
|
||||
env: map[string]string{"GH_COLOR_LABELS": "yes"},
|
||||
colorLabelsEnabled: true,
|
||||
},
|
||||
{
|
||||
name: "colorLabels disable via empty string in GH_COLOR_LABELS env var",
|
||||
env: map[string]string{"GH_COLOR_LABELS": ""},
|
||||
colorLabelsEnabled: false,
|
||||
},
|
||||
{
|
||||
name: "colorLabels disabled via `0` in GH_COLOR_LABELS env var",
|
||||
env: map[string]string{"GH_COLOR_LABELS": "0"},
|
||||
colorLabelsEnabled: false,
|
||||
},
|
||||
{
|
||||
name: "colorLabels disabled via `false` in GH_COLOR_LABELS env var",
|
||||
env: map[string]string{"GH_COLOR_LABELS": "false"},
|
||||
colorLabelsEnabled: false,
|
||||
},
|
||||
{
|
||||
name: "colorLabels disabled via `no` in GH_COLOR_LABELS env var",
|
||||
env: map[string]string{"GH_COLOR_LABELS": "no"},
|
||||
colorLabelsEnabled: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if tt.env != nil {
|
||||
for k, v := range tt.env {
|
||||
t.Setenv(k, v)
|
||||
}
|
||||
}
|
||||
f := New("1")
|
||||
f.Config = func() (gh.Config, error) {
|
||||
if tt.config == nil {
|
||||
return config.NewBlankConfig(), nil
|
||||
} else {
|
||||
return tt.config, nil
|
||||
}
|
||||
}
|
||||
io := ioStreams(f)
|
||||
assert.Equal(t, tt.colorLabelsEnabled, io.ColorLabels())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSSOURL(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
@ -537,3 +615,11 @@ func pagerConfig() gh.Config {
|
|||
func disablePromptConfig() gh.Config {
|
||||
return config.NewFromString("prompt: disabled")
|
||||
}
|
||||
|
||||
func disableColorLabelsConfig() gh.Config {
|
||||
return config.NewFromString("color_labels: disabled")
|
||||
}
|
||||
|
||||
func enableColorLabelsConfig() gh.Config {
|
||||
return config.NewFromString("color_labels: enabled")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ func createRun(opts *CreateOptions) error {
|
|||
processMessage = fmt.Sprintf("Creating gist %s", gistName)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(errOut, "%s %s\n", cs.Gray("-"), processMessage)
|
||||
fmt.Fprintf(errOut, "%s %s\n", cs.Muted("-"), processMessage)
|
||||
|
||||
httpClient, err := opts.HttpClient()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -654,50 +654,57 @@ func Test_highlightMatch(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
color bool
|
||||
cs *iostreams.ColorScheme
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "single match",
|
||||
input: "Octo",
|
||||
cs: &iostreams.ColorScheme{},
|
||||
want: "Octo",
|
||||
},
|
||||
{
|
||||
name: "single match (color)",
|
||||
input: "Octo",
|
||||
color: true,
|
||||
want: "\x1b[0;30;43mOcto\x1b[0m",
|
||||
cs: &iostreams.ColorScheme{
|
||||
Enabled: true,
|
||||
},
|
||||
want: "\x1b[0;30;43mOcto\x1b[0m",
|
||||
},
|
||||
{
|
||||
name: "single match with extra",
|
||||
input: "Hello, Octocat!",
|
||||
cs: &iostreams.ColorScheme{},
|
||||
want: "Hello, Octocat!",
|
||||
},
|
||||
{
|
||||
name: "single match with extra (color)",
|
||||
input: "Hello, Octocat!",
|
||||
color: true,
|
||||
want: "\x1b[0;34mHello, \x1b[0m\x1b[0;30;43mOcto\x1b[0m\x1b[0;34mcat!\x1b[0m",
|
||||
cs: &iostreams.ColorScheme{
|
||||
Enabled: true,
|
||||
},
|
||||
want: "\x1b[0;34mHello, \x1b[0m\x1b[0;30;43mOcto\x1b[0m\x1b[0;34mcat!\x1b[0m",
|
||||
},
|
||||
{
|
||||
name: "multiple matches",
|
||||
input: "Octocat/octo",
|
||||
cs: &iostreams.ColorScheme{},
|
||||
want: "Octocat/octo",
|
||||
},
|
||||
{
|
||||
name: "multiple matches (color)",
|
||||
input: "Octocat/octo",
|
||||
color: true,
|
||||
want: "\x1b[0;30;43mOcto\x1b[0m\x1b[0;34mcat/\x1b[0m\x1b[0;30;43mocto\x1b[0m",
|
||||
cs: &iostreams.ColorScheme{
|
||||
Enabled: true,
|
||||
},
|
||||
want: "\x1b[0;30;43mOcto\x1b[0m\x1b[0;34mcat/\x1b[0m\x1b[0;30;43mocto\x1b[0m",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cs := iostreams.NewColorScheme(tt.color, false, false, false, iostreams.NoTheme)
|
||||
|
||||
matched := false
|
||||
got, err := highlightMatch(tt.input, regex, &matched, cs.Blue, cs.Highlight)
|
||||
got, err := highlightMatch(tt.input, regex, &matched, tt.cs.Blue, tt.cs.Highlight)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, matched)
|
||||
assert.Equal(t, tt.want, got)
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ func PromptGists(prompter prompter.Prompter, client *http.Client, host string, c
|
|||
for i, gist := range gists {
|
||||
gistTime := text.FuzzyAgo(time.Now(), gist.UpdatedAt)
|
||||
// TODO: support dynamic maxWidth
|
||||
opts[i] = fmt.Sprintf("%s %s %s", cs.Bold(gist.Filename()), gist.TruncDescription(), cs.Gray(gistTime))
|
||||
opts[i] = fmt.Sprintf("%s %s %s", cs.Bold(gist.Filename()), gist.TruncDescription(), cs.Muted(gistTime))
|
||||
}
|
||||
|
||||
result, err := prompter.Select("Select a gist", "", opts)
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ func viewRun(opts *ViewOptions) error {
|
|||
if len(gist.Files) == 1 || opts.Filename != "" {
|
||||
return fmt.Errorf("error: file is binary")
|
||||
}
|
||||
_, err = fmt.Fprintln(opts.IO.Out, cs.Gray("(skipping rendering binary content)"))
|
||||
_, err = fmt.Fprintln(opts.IO.Out, cs.Muted("(skipping rendering binary content)"))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ func viewRun(opts *ViewOptions) error {
|
|||
|
||||
for i, fn := range filenames {
|
||||
if showFilenames {
|
||||
fmt.Fprintf(opts.IO.Out, "%s\n\n", cs.Gray(fn))
|
||||
fmt.Fprintf(opts.IO.Out, "%s\n\n", cs.Muted(fn))
|
||||
}
|
||||
if err := render(gist.Files[fn]); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ func PrintIssues(io *iostreams.IOStreams, now time.Time, prefix string, totalCou
|
|||
}
|
||||
table.AddField(text.RemoveExcessiveWhitespace(issue.Title))
|
||||
table.AddField(issueLabelList(&issue, cs, isTTY))
|
||||
table.AddTimeField(now, issue.UpdatedAt, cs.Gray)
|
||||
table.AddTimeField(now, issue.UpdatedAt, cs.Muted)
|
||||
table.EndRow()
|
||||
}
|
||||
_ = table.Render()
|
||||
remaining := totalCount - len(issues)
|
||||
if remaining > 0 {
|
||||
fmt.Fprintf(io.Out, cs.Gray("%sAnd %d more\n"), prefix, remaining)
|
||||
fmt.Fprintf(io.Out, cs.Muted("%sAnd %d more\n"), prefix, remaining)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ func issueLabelList(issue *api.Issue, cs *iostreams.ColorScheme, colorize bool)
|
|||
labelNames := make([]string, 0, len(issue.Labels.Nodes))
|
||||
for _, label := range issue.Labels.Nodes {
|
||||
if colorize {
|
||||
labelNames = append(labelNames, cs.HexToRGB(label.Color, label.Name))
|
||||
labelNames = append(labelNames, cs.Label(label.Color, label.Name))
|
||||
} else {
|
||||
labelNames = append(labelNames, label.Name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ func printHumanIssuePreview(opts *ViewOptions, baseRepo ghrepo.Interface, issue
|
|||
var md string
|
||||
var err error
|
||||
if issue.Body == "" {
|
||||
md = fmt.Sprintf("\n %s\n\n", cs.Gray("No description provided"))
|
||||
md = fmt.Sprintf("\n %s\n\n", cs.Muted("No description provided"))
|
||||
} else {
|
||||
md, err = markdown.Render(issue.Body,
|
||||
markdown.WithTheme(opts.IO.TerminalTheme()),
|
||||
|
|
@ -250,7 +250,7 @@ func printHumanIssuePreview(opts *ViewOptions, baseRepo ghrepo.Interface, issue
|
|||
}
|
||||
|
||||
// Footer
|
||||
fmt.Fprintf(out, cs.Gray("View this issue on GitHub: %s\n"), issue.URL)
|
||||
fmt.Fprintf(out, cs.Muted("View this issue on GitHub: %s\n"), issue.URL)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -317,7 +317,7 @@ func issueLabelList(issue *api.Issue, cs *iostreams.ColorScheme) string {
|
|||
if cs == nil {
|
||||
labelNames[i] = label.Name
|
||||
} else {
|
||||
labelNames[i] = cs.HexToRGB(label.Color, label.Name)
|
||||
labelNames[i] = cs.Label(label.Color, label.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,12 @@ func printLabels(io *iostreams.IOStreams, labels []label) error {
|
|||
table := tableprinter.New(io, tableprinter.WithHeader("NAME", "DESCRIPTION", "COLOR"))
|
||||
|
||||
for _, label := range labels {
|
||||
table.AddField(label.Name, tableprinter.WithColor(cs.ColorFromRGB(label.Color)))
|
||||
// Colorize the label using tableprinter's WithColor function for it to handle non-TTY situations
|
||||
labelColor := tableprinter.WithColor(func(s string) string {
|
||||
return cs.Label(label.Color, s)
|
||||
})
|
||||
|
||||
table.AddField(label.Name, labelColor)
|
||||
table.AddField(label.Description)
|
||||
table.AddField("#" + label.Color)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func addRow(tp *tableprinter.TablePrinter, io *iostreams.IOStreams, o check) {
|
|||
markColor = cs.Yellow
|
||||
case "skipping", "cancel":
|
||||
mark = "-"
|
||||
markColor = cs.Gray
|
||||
markColor = cs.Muted
|
||||
}
|
||||
|
||||
if io.IsStdoutTTY() {
|
||||
|
|
|
|||
|
|
@ -879,37 +879,37 @@ func renderPullRequestPlain(w io.Writer, params map[string]interface{}, state *s
|
|||
}
|
||||
|
||||
func renderPullRequestTTY(io *iostreams.IOStreams, params map[string]interface{}, state *shared.IssueMetadataState) error {
|
||||
iofmt := io.ColorScheme()
|
||||
cs := io.ColorScheme()
|
||||
out := io.Out
|
||||
|
||||
fmt.Fprint(out, "Would have created a Pull Request with:\n")
|
||||
fmt.Fprintf(out, "%s: %s\n", iofmt.Bold("Title"), params["title"].(string))
|
||||
fmt.Fprintf(out, "%s: %t\n", iofmt.Bold("Draft"), params["draft"])
|
||||
fmt.Fprintf(out, "%s: %s\n", iofmt.Bold("Base"), params["baseRefName"])
|
||||
fmt.Fprintf(out, "%s: %s\n", iofmt.Bold("Head"), params["headRefName"])
|
||||
fmt.Fprintf(out, "%s: %s\n", cs.Bold("Title"), params["title"].(string))
|
||||
fmt.Fprintf(out, "%s: %t\n", cs.Bold("Draft"), params["draft"])
|
||||
fmt.Fprintf(out, "%s: %s\n", cs.Bold("Base"), params["baseRefName"])
|
||||
fmt.Fprintf(out, "%s: %s\n", cs.Bold("Head"), params["headRefName"])
|
||||
if len(state.Labels) != 0 {
|
||||
fmt.Fprintf(out, "%s: %s\n", iofmt.Bold("Labels"), strings.Join(state.Labels, ", "))
|
||||
fmt.Fprintf(out, "%s: %s\n", cs.Bold("Labels"), strings.Join(state.Labels, ", "))
|
||||
}
|
||||
if len(state.Reviewers) != 0 {
|
||||
fmt.Fprintf(out, "%s: %s\n", iofmt.Bold("Reviewers"), strings.Join(state.Reviewers, ", "))
|
||||
fmt.Fprintf(out, "%s: %s\n", cs.Bold("Reviewers"), strings.Join(state.Reviewers, ", "))
|
||||
}
|
||||
if len(state.Assignees) != 0 {
|
||||
fmt.Fprintf(out, "%s: %s\n", iofmt.Bold("Assignees"), strings.Join(state.Assignees, ", "))
|
||||
fmt.Fprintf(out, "%s: %s\n", cs.Bold("Assignees"), strings.Join(state.Assignees, ", "))
|
||||
}
|
||||
if len(state.Milestones) != 0 {
|
||||
fmt.Fprintf(out, "%s: %s\n", iofmt.Bold("Milestones"), strings.Join(state.Milestones, ", "))
|
||||
fmt.Fprintf(out, "%s: %s\n", cs.Bold("Milestones"), strings.Join(state.Milestones, ", "))
|
||||
}
|
||||
if len(state.Projects) != 0 {
|
||||
fmt.Fprintf(out, "%s: %s\n", iofmt.Bold("Projects"), strings.Join(state.Projects, ", "))
|
||||
fmt.Fprintf(out, "%s: %s\n", cs.Bold("Projects"), strings.Join(state.Projects, ", "))
|
||||
}
|
||||
fmt.Fprintf(out, "%s: %t\n", iofmt.Bold("MaintainerCanModify"), params["maintainerCanModify"])
|
||||
fmt.Fprintf(out, "%s: %t\n", cs.Bold("MaintainerCanModify"), params["maintainerCanModify"])
|
||||
|
||||
fmt.Fprintf(out, "%s\n", iofmt.Bold("Body:"))
|
||||
fmt.Fprintf(out, "%s\n", cs.Bold("Body:"))
|
||||
// Body
|
||||
var md string
|
||||
var err error
|
||||
if len(params["body"].(string)) == 0 {
|
||||
md = fmt.Sprintf("%s\n", iofmt.Gray("No description provided"))
|
||||
md = fmt.Sprintf("%s\n", cs.Muted("No description provided"))
|
||||
} else {
|
||||
md, err = markdown.Render(params["body"].(string),
|
||||
markdown.WithTheme(io.TerminalTheme()),
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ func reviewRun(opts *ReviewOptions) error {
|
|||
|
||||
switch reviewData.State {
|
||||
case api.ReviewComment:
|
||||
fmt.Fprintf(opts.IO.ErrOut, "%s Reviewed pull request %s#%d\n", cs.Gray("-"), ghrepo.FullName(baseRepo), pr.Number)
|
||||
fmt.Fprintf(opts.IO.ErrOut, "%s Reviewed pull request %s#%d\n", cs.Muted("-"), ghrepo.FullName(baseRepo), pr.Number)
|
||||
case api.ReviewApprove:
|
||||
fmt.Fprintf(opts.IO.ErrOut, "%s Approved pull request %s#%d\n", cs.SuccessIcon(), ghrepo.FullName(baseRepo), pr.Number)
|
||||
case api.ReviewRequestChanges:
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func CommentList(io *iostreams.IOStreams, comments api.Comments, reviews api.Pul
|
|||
hiddenCount := totalCount - retrievedCount
|
||||
|
||||
if preview && hiddenCount > 0 {
|
||||
fmt.Fprint(&b, cs.Gray(fmt.Sprintf("———————— Not showing %s ————————", text.Pluralize(hiddenCount, "comment"))))
|
||||
fmt.Fprint(&b, cs.Muted(fmt.Sprintf("———————— Not showing %s ————————", text.Pluralize(hiddenCount, "comment"))))
|
||||
fmt.Fprintf(&b, "\n\n\n")
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ func CommentList(io *iostreams.IOStreams, comments api.Comments, reviews api.Pul
|
|||
}
|
||||
|
||||
if preview && hiddenCount > 0 {
|
||||
fmt.Fprint(&b, cs.Gray("Use --comments to view the full conversation"))
|
||||
fmt.Fprint(&b, cs.Muted("Use --comments to view the full conversation"))
|
||||
fmt.Fprintln(&b)
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ func formatComment(io *iostreams.IOStreams, comment Comment, newest bool) (strin
|
|||
var md string
|
||||
var err error
|
||||
if comment.Content() == "" {
|
||||
md = fmt.Sprintf("\n %s\n\n", cs.Gray("No body provided"))
|
||||
md = fmt.Sprintf("\n %s\n\n", cs.Muted("No body provided"))
|
||||
} else {
|
||||
md, err = markdown.Render(comment.Content(),
|
||||
markdown.WithTheme(io.TerminalTheme()),
|
||||
|
|
@ -135,7 +135,7 @@ func formatComment(io *iostreams.IOStreams, comment Comment, newest bool) (strin
|
|||
|
||||
// Footer
|
||||
if comment.Link() != "" {
|
||||
fmt.Fprintf(&b, cs.Gray("View the full review: %s\n\n"), comment.Link())
|
||||
fmt.Fprintf(&b, cs.Muted("View the full review: %s\n\n"), comment.Link())
|
||||
}
|
||||
|
||||
return b.String(), nil
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func PrintHeader(io *iostreams.IOStreams, s string) {
|
|||
}
|
||||
|
||||
func PrintMessage(io *iostreams.IOStreams, s string) {
|
||||
fmt.Fprintln(io.Out, io.ColorScheme().Gray(s))
|
||||
fmt.Fprintln(io.Out, io.ColorScheme().Muted(s))
|
||||
}
|
||||
|
||||
func ListNoResults(repoName string, itemName string, hasFilters bool) error {
|
||||
|
|
@ -83,7 +83,7 @@ func ListHeader(repoName string, itemName string, matchCount int, totalMatchCoun
|
|||
}
|
||||
|
||||
func PrCheckStatusSummaryWithColor(cs *iostreams.ColorScheme, checks api.PullRequestChecksStatus) string {
|
||||
var summary = cs.Gray("No checks")
|
||||
var summary = cs.Muted("No checks")
|
||||
if checks.Total > 0 {
|
||||
if checks.Failing > 0 {
|
||||
if checks.Failing == checks.Total {
|
||||
|
|
|
|||
|
|
@ -316,6 +316,6 @@ func printPrs(io *iostreams.IOStreams, totalCount int, prs ...api.PullRequest) {
|
|||
}
|
||||
remaining := totalCount - len(prs)
|
||||
if remaining > 0 {
|
||||
fmt.Fprintf(w, cs.Gray(" And %d more\n"), remaining)
|
||||
fmt.Fprintln(w, cs.Mutedf(" And %d more", remaining))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ func printHumanPrPreview(opts *ViewOptions, baseRepo ghrepo.Interface, pr *api.P
|
|||
var md string
|
||||
var err error
|
||||
if pr.Body == "" {
|
||||
md = fmt.Sprintf("\n %s\n\n", cs.Gray("No description provided"))
|
||||
md = fmt.Sprintf("\n %s\n\n", cs.Muted("No description provided"))
|
||||
} else {
|
||||
md, err = markdown.Render(pr.Body,
|
||||
markdown.WithTheme(opts.IO.TerminalTheme()),
|
||||
|
|
@ -282,7 +282,7 @@ func printHumanPrPreview(opts *ViewOptions, baseRepo ghrepo.Interface, pr *api.P
|
|||
}
|
||||
|
||||
// Footer
|
||||
fmt.Fprintf(out, cs.Gray("View this pull request on GitHub: %s\n"), pr.URL)
|
||||
fmt.Fprintf(out, cs.Muted("View this pull request on GitHub: %s\n"), pr.URL)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -423,7 +423,7 @@ func prLabelList(pr api.PullRequest, cs *iostreams.ColorScheme) string {
|
|||
|
||||
labelNames := make([]string, 0, len(pr.Labels.Nodes))
|
||||
for _, label := range pr.Labels.Nodes {
|
||||
labelNames = append(labelNames, cs.HexToRGB(label.Color, label.Name))
|
||||
labelNames = append(labelNames, cs.Label(label.Color, label.Name))
|
||||
}
|
||||
|
||||
list := strings.Join(labelNames, ", ")
|
||||
|
|
|
|||
|
|
@ -129,19 +129,19 @@ func viewRun(opts *ViewOptions) error {
|
|||
}
|
||||
|
||||
func renderReleaseTTY(io *iostreams.IOStreams, release *shared.Release) error {
|
||||
iofmt := io.ColorScheme()
|
||||
cs := io.ColorScheme()
|
||||
w := io.Out
|
||||
|
||||
fmt.Fprintf(w, "%s\n", iofmt.Bold(release.TagName))
|
||||
fmt.Fprintf(w, "%s\n", cs.Bold(release.TagName))
|
||||
if release.IsDraft {
|
||||
fmt.Fprintf(w, "%s • ", iofmt.Red("Draft"))
|
||||
fmt.Fprintf(w, "%s • ", cs.Red("Draft"))
|
||||
} else if release.IsPrerelease {
|
||||
fmt.Fprintf(w, "%s • ", iofmt.Yellow("Pre-release"))
|
||||
fmt.Fprintf(w, "%s • ", cs.Yellow("Pre-release"))
|
||||
}
|
||||
if release.IsDraft {
|
||||
fmt.Fprintf(w, "%s\n", iofmt.Gray(fmt.Sprintf("%s created this %s", release.Author.Login, text.FuzzyAgo(time.Now(), release.CreatedAt))))
|
||||
fmt.Fprintln(w, cs.Mutedf("%s created this %s", release.Author.Login, text.FuzzyAgo(time.Now(), release.CreatedAt)))
|
||||
} else {
|
||||
fmt.Fprintf(w, "%s\n", iofmt.Gray(fmt.Sprintf("%s released this %s", release.Author.Login, text.FuzzyAgo(time.Now(), *release.PublishedAt))))
|
||||
fmt.Fprintln(w, cs.Mutedf("%s released this %s", release.Author.Login, text.FuzzyAgo(time.Now(), *release.PublishedAt)))
|
||||
}
|
||||
|
||||
renderedDescription, err := markdown.Render(release.Body,
|
||||
|
|
@ -153,7 +153,7 @@ func renderReleaseTTY(io *iostreams.IOStreams, release *shared.Release) error {
|
|||
fmt.Fprintln(w, renderedDescription)
|
||||
|
||||
if len(release.Assets) > 0 {
|
||||
fmt.Fprintf(w, "%s\n", iofmt.Bold("Assets"))
|
||||
fmt.Fprintln(w, cs.Bold("Assets"))
|
||||
//nolint:staticcheck // SA1019: Showing NAME|SIZE headers adds nothing to table.
|
||||
table := tableprinter.New(io, tableprinter.NoHeader)
|
||||
for _, a := range release.Assets {
|
||||
|
|
@ -168,7 +168,7 @@ func renderReleaseTTY(io *iostreams.IOStreams, release *shared.Release) error {
|
|||
fmt.Fprint(w, "\n")
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "%s\n", iofmt.Gray(fmt.Sprintf("View on GitHub: %s", release.URL)))
|
||||
fmt.Fprintln(w, cs.Mutedf("View on GitHub: %s", release.URL))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,9 +119,9 @@ func renderLicense(license *api.License, opts *ViewOptions) error {
|
|||
cs := opts.IO.ColorScheme()
|
||||
var out strings.Builder
|
||||
if opts.IO.IsStdoutTTY() {
|
||||
out.WriteString(fmt.Sprintf("\n%s\n", cs.Gray(license.Description)))
|
||||
out.WriteString(fmt.Sprintf("\n%s\n", cs.Grayf("To implement: %s", license.Implementation)))
|
||||
out.WriteString(fmt.Sprintf("\n%s\n\n", cs.Grayf("For more information, see: %s", license.HTMLURL)))
|
||||
out.WriteString(fmt.Sprintf("\n%s\n", cs.Muted(license.Description)))
|
||||
out.WriteString(fmt.Sprintf("\n%s\n", cs.Mutedf("To implement: %s", license.Implementation)))
|
||||
out.WriteString(fmt.Sprintf("\n%s\n\n", cs.Mutedf("For more information, see: %s", license.HTMLURL)))
|
||||
}
|
||||
out.WriteString(license.Body)
|
||||
_, err := opts.IO.Out.Write([]byte(out.String()))
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ func viewRun(opts *ViewOptions) error {
|
|||
|
||||
var readmeContent string
|
||||
if readme == nil {
|
||||
readmeContent = cs.Gray("This repository does not have a README")
|
||||
readmeContent = cs.Muted("This repository does not have a README")
|
||||
} else if isMarkdownFile(readme.Filename) {
|
||||
var err error
|
||||
readmeContent, err = markdown.Render(readme.Content,
|
||||
|
|
@ -197,7 +197,7 @@ func viewRun(opts *ViewOptions) error {
|
|||
|
||||
description := repo.Description
|
||||
if description == "" {
|
||||
description = cs.Gray("No description provided")
|
||||
description = cs.Muted("No description provided")
|
||||
}
|
||||
|
||||
repoData := struct {
|
||||
|
|
@ -209,7 +209,7 @@ func viewRun(opts *ViewOptions) error {
|
|||
FullName: cs.Bold(fullName),
|
||||
Description: description,
|
||||
Readme: readmeContent,
|
||||
View: cs.Gray(fmt.Sprintf("View this repository on GitHub: %s", openURL)),
|
||||
View: cs.Mutedf("View this repository on GitHub: %s", openURL),
|
||||
}
|
||||
|
||||
return tmpl.Execute(stdout, repoData)
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func isRootCmd(command *cobra.Command) bool {
|
|||
return command != nil && !command.HasParent()
|
||||
}
|
||||
|
||||
func rootHelpFunc(f *cmdutil.Factory, command *cobra.Command, args []string) {
|
||||
func rootHelpFunc(f *cmdutil.Factory, command *cobra.Command, _ []string) {
|
||||
flags := command.Flags()
|
||||
|
||||
if isRootCmd(command) {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ var HelpTopics = []helpTopic{
|
|||
%[1]sCLICOLOR_FORCE%[1]s: set to a value other than %[1]s0%[1]s to keep ANSI colors in output
|
||||
even when the output is piped.
|
||||
|
||||
%[1]sGH_COLOR_LABELS%[1]s: set to any value to display labels using their RGB hex color codes in terminals that
|
||||
support truecolor.
|
||||
|
||||
%[1]sGH_FORCE_TTY%[1]s: set to any value to force terminal-style output even when the output is
|
||||
redirected. When the value is a number, it is interpreted as the number of columns
|
||||
available in the viewport. When the value is a percentage, it will be applied against
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ func RenderAnnotations(cs *iostreams.ColorScheme, annotations []Annotation) stri
|
|||
|
||||
for _, a := range annotations {
|
||||
lines = append(lines, fmt.Sprintf("%s %s", AnnotationSymbol(cs, a), a.Message))
|
||||
lines = append(lines, cs.Grayf("%s: %s#%d\n", a.JobName, a.Path, a.StartLine))
|
||||
// Following newline is essential for spacing between annotations
|
||||
lines = append(lines, cs.Mutedf("%s: %s#%d\n", a.JobName, a.Path, a.StartLine))
|
||||
}
|
||||
|
||||
return strings.Join(lines, "\n")
|
||||
|
|
|
|||
|
|
@ -575,7 +575,7 @@ func Symbol(cs *iostreams.ColorScheme, status Status, conclusion Conclusion) (st
|
|||
case Success:
|
||||
return cs.SuccessIconWithColor(noColor), cs.Green
|
||||
case Skipped, Neutral:
|
||||
return "-", cs.Gray
|
||||
return "-", cs.Muted
|
||||
default:
|
||||
return cs.FailureIconWithColor(noColor), cs.Red
|
||||
}
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ func runView(opts *ViewOptions) error {
|
|||
for _, a := range artifacts {
|
||||
expiredBadge := ""
|
||||
if a.Expired {
|
||||
expiredBadge = cs.Gray(" (expired)")
|
||||
expiredBadge = cs.Muted(" (expired)")
|
||||
}
|
||||
fmt.Fprintf(out, "%s%s\n", a.Name, expiredBadge)
|
||||
}
|
||||
|
|
@ -411,7 +411,7 @@ func runView(opts *ViewOptions) error {
|
|||
} else {
|
||||
fmt.Fprintf(out, "For more information about a job, try: gh run view --job=<job-id>\n")
|
||||
}
|
||||
fmt.Fprintf(out, cs.Gray("View this run on GitHub: %s\n"), run.URL)
|
||||
fmt.Fprintln(out, cs.Mutedf("View this run on GitHub: %s", run.URL))
|
||||
|
||||
if opts.ExitStatus && shared.IsFailureState(run.Conclusion) {
|
||||
return cmdutil.SilentError
|
||||
|
|
@ -423,7 +423,7 @@ func runView(opts *ViewOptions) error {
|
|||
} else {
|
||||
fmt.Fprintf(out, "To see the full job log, try: gh run view --log --job=%d\n", selectedJob.ID)
|
||||
}
|
||||
fmt.Fprintf(out, cs.Gray("View this run on GitHub: %s\n"), run.URL)
|
||||
fmt.Fprintln(out, cs.Mutedf("View this run on GitHub: %s", run.URL))
|
||||
|
||||
if opts.ExitStatus && shared.IsFailureState(selectedJob.Conclusion) {
|
||||
return cmdutil.SilentError
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ func displayResults(io *iostreams.IOStreams, now time.Time, results search.Commi
|
|||
tp.AddField(commit.Sha)
|
||||
tp.AddField(text.RemoveExcessiveWhitespace(commit.Info.Message))
|
||||
tp.AddField(commit.Author.Login)
|
||||
tp.AddTimeField(now, commit.Info.Author.Date, cs.Gray)
|
||||
tp.AddTimeField(now, commit.Info.Author.Date, cs.Muted)
|
||||
tp.EndRow()
|
||||
}
|
||||
if io.IsStdoutTTY() {
|
||||
|
|
|
|||
|
|
@ -171,14 +171,14 @@ func displayResults(io *iostreams.IOStreams, now time.Time, results search.Repos
|
|||
tags = append(tags, "archived")
|
||||
}
|
||||
info := strings.Join(tags, ", ")
|
||||
infoColor := cs.Gray
|
||||
infoColor := cs.Muted
|
||||
if repo.IsPrivate {
|
||||
infoColor = cs.Yellow
|
||||
}
|
||||
tp.AddField(repo.FullName, tableprinter.WithColor(cs.Bold))
|
||||
tp.AddField(text.RemoveExcessiveWhitespace(repo.Description))
|
||||
tp.AddField(info, tableprinter.WithColor(infoColor))
|
||||
tp.AddTimeField(now, repo.UpdatedAt, cs.Gray)
|
||||
tp.AddTimeField(now, repo.UpdatedAt, cs.Muted)
|
||||
tp.EndRow()
|
||||
}
|
||||
if io.IsStdoutTTY() {
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func displayIssueResults(io *iostreams.IOStreams, now time.Time, et EntityType,
|
|||
}
|
||||
tp.AddField(text.RemoveExcessiveWhitespace(issue.Title))
|
||||
tp.AddField(listIssueLabels(&issue, cs, tp.IsTTY()))
|
||||
tp.AddTimeField(now, issue.UpdatedAt, cs.Gray)
|
||||
tp.AddTimeField(now, issue.UpdatedAt, cs.Muted)
|
||||
tp.EndRow()
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ func listIssueLabels(issue *search.Issue, cs *iostreams.ColorScheme, colorize bo
|
|||
labelNames := make([]string, 0, len(issue.Labels))
|
||||
for _, label := range issue.Labels {
|
||||
if colorize {
|
||||
labelNames = append(labelNames, cs.HexToRGB(label.Color, label.Name))
|
||||
labelNames = append(labelNames, cs.Label(label.Color, label.Name))
|
||||
} else {
|
||||
labelNames = append(labelNames, label.Name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -740,7 +740,7 @@ func statusRun(opts *StatusOptions) error {
|
|||
errs := sg.authErrors.ToSlice()
|
||||
sort.Strings(errs)
|
||||
for _, msg := range errs {
|
||||
fmt.Fprintln(out, cs.Gray(fmt.Sprintf("warning: %s", msg)))
|
||||
fmt.Fprintln(out, cs.Mutedf("warning: %s", msg))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ func viewWorkflowContent(opts *ViewOptions, client *api.Client, repo ghrepo.Inte
|
|||
out := opts.IO.Out
|
||||
|
||||
fileName := workflow.Base()
|
||||
fmt.Fprintf(out, "%s - %s\n", cs.Bold(workflow.Name), cs.Gray(fileName))
|
||||
fmt.Fprintf(out, "%s - %s\n", cs.Bold(workflow.Name), cs.Muted(fileName))
|
||||
fmt.Fprintf(out, "ID: %s", cs.Cyanf("%d", workflow.ID))
|
||||
|
||||
codeBlock := fmt.Sprintf("```yaml\n%s\n```", yaml)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue