diff --git a/api/queries_pr.go b/api/queries_pr.go index b6fdcb271..f18b0bad0 100644 --- a/api/queries_pr.go +++ b/api/queries_pr.go @@ -40,6 +40,7 @@ type PullRequest struct { } } IsCrossRepository bool + IsDraft bool MaintainerCanModify bool ReviewDecision string @@ -156,6 +157,7 @@ func PullRequests(client *Client, repo ghrepo.Interface, currentPRNumber int, cu login } isCrossRepository + isDraft commits(last: 1) { nodes { commit { @@ -366,6 +368,7 @@ func PullRequestForBranch(client *Client, repo ghrepo.Interface, branch string) login } isCrossRepository + isDraft } } } @@ -460,6 +463,7 @@ func PullRequestList(client *Client, vars map[string]interface{}, limit int) ([] login } isCrossRepository + isDraft } ` diff --git a/command/pr.go b/command/pr.go index cd767f13d..221ef0bc4 100644 --- a/command/pr.go +++ b/command/pr.go @@ -214,7 +214,7 @@ func prList(cmd *cobra.Command, args []string) error { if table.IsTTY() { prNum = "#" + prNum } - table.AddField(prNum, nil, colorFuncForState(pr.State)) + table.AddField(prNum, nil, colorFuncForPR(pr)) table.AddField(replaceExcessiveWhitespace(pr.Title), nil, nil) table.AddField(pr.HeadLabel(), nil, utils.Cyan) table.EndRow() @@ -227,6 +227,14 @@ func prList(cmd *cobra.Command, args []string) error { return nil } +func colorFuncForPR(pr api.PullRequest) func(string) string { + if pr.State == "OPEN" && pr.IsDraft { + return utils.Gray + } else { + return colorFuncForState(pr.State) + } +} + func colorFuncForState(state string) func(string) string { switch state { case "OPEN": @@ -385,7 +393,13 @@ func prSelectorForCurrentBranch(ctx context.Context) (prNumber int, prHeadRef st func printPrs(w io.Writer, totalCount int, prs ...api.PullRequest) { for _, pr := range prs { prNumber := fmt.Sprintf("#%d", pr.Number) - fmt.Fprintf(w, " %s %s %s", utils.Green(prNumber), text.Truncate(50, replaceExcessiveWhitespace(pr.Title)), utils.Cyan("["+pr.HeadLabel()+"]")) + + prNumberColorFunc := utils.Green + if pr.IsDraft { + prNumberColorFunc = utils.Gray + } + + fmt.Fprintf(w, " %s %s %s", prNumberColorFunc(prNumber), text.Truncate(50, replaceExcessiveWhitespace(pr.Title)), utils.Cyan("["+pr.HeadLabel()+"]")) checks := pr.ChecksStatus() reviews := pr.ReviewStatus()