From 9944698665ca459823ef0aa61757d015a72ae169 Mon Sep 17 00:00:00 2001 From: Gowtham Munukutla Date: Fri, 5 Mar 2021 11:20:49 +0530 Subject: [PATCH] Add additions and deletions in pr view --- api/queries_pr.go | 4 ++++ pkg/cmd/pr/view/view.go | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/api/queries_pr.go b/api/queries_pr.go index d3e8d1490..bed79a2de 100644 --- a/api/queries_pr.go +++ b/api/queries_pr.go @@ -39,6 +39,8 @@ type PullRequest struct { HeadRefName string Body string Mergeable string + Additions int + Deletions int MergeStateStatus string Author struct { @@ -571,6 +573,8 @@ func PullRequestByNumber(client *Client, repo ghrepo.Interface, number int) (*Pu closed body mergeable + additions + deletions author { login } diff --git a/pkg/cmd/pr/view/view.go b/pkg/cmd/pr/view/view.go index e78a192df..705341c73 100644 --- a/pkg/cmd/pr/view/view.go +++ b/pkg/cmd/pr/view/view.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" "sort" + "strconv" "strings" "sync" @@ -151,12 +152,16 @@ func printHumanPrPreview(opts *ViewOptions, pr *api.PullRequest) error { // Header (Title and State) fmt.Fprintln(out, cs.Bold(pr.Title)) fmt.Fprintf(out, - "%s • %s wants to merge %s into %s from %s\n", + "%s • %s wants to merge %s into %s from %s • %s%s %s%s \n", shared.StateTitleWithColor(cs, *pr), pr.Author.Login, utils.Pluralize(pr.Commits.TotalCount, "commit"), pr.BaseRefName, pr.HeadRefName, + cs.Green("+"), + cs.Green(strconv.Itoa(pr.Additions)), + cs.Red("-"), + cs.Red(strconv.Itoa(pr.Deletions)), ) // Reactions