Merge remote-tracking branch 'origin/master' into pr-checkout

This commit is contained in:
Mislav Marohnić 2019-11-15 09:31:11 +01:00
commit 760fac906d
4 changed files with 26 additions and 5 deletions

View file

@ -38,6 +38,7 @@ type PullRequest struct {
}
}
}
Commits struct {
Nodes []struct {
Commit struct {
@ -60,6 +61,13 @@ type PullRequest struct {
}
}
func (pr PullRequest) HeadLabel() string {
if pr.IsCrossRepository {
return fmt.Sprintf("%s:%s", pr.HeadRepositoryOwner.Login, pr.HeadRefName)
}
return pr.HeadRefName
}
type PullRequestReviewStatus struct {
ChangesRequested bool
Approved bool
@ -258,6 +266,11 @@ func PullRequests(client *Client, ghRepo Repo, currentBranch, currentUsername st
title
url
headRefName
headRefName
headRepositoryOwner {
login
}
isCrossRepository
commits(last: 1) {
nodes {
commit {
@ -536,6 +549,10 @@ func PullRequestList(client *Client, vars map[string]interface{}, limit int) ([]
state
url
headRefName
headRepositoryOwner {
login
}
isCrossRepository
}
}
pageInfo {

View file

@ -209,10 +209,10 @@ func prList(cmd *cobra.Command, args []string) error {
case "MERGED":
prNum = utils.Magenta(prNum)
}
prBranch := utils.Cyan(truncate(branchWidth, pr.HeadRefName))
prBranch := utils.Cyan(truncate(branchWidth, pr.HeadLabel()))
fmt.Fprintf(out, "%s %-*s %s\n", prNum, titleWidth, truncate(titleWidth, pr.Title), prBranch)
} else {
fmt.Fprintf(out, "%d\t%s\t%s\n", pr.Number, pr.Title, pr.HeadRefName)
fmt.Fprintf(out, "%d\t%s\t%s\n", pr.Number, pr.Title, pr.HeadLabel())
}
}
return nil
@ -353,7 +353,7 @@ func prCheckout(cmd *cobra.Command, args []string) error {
func printPrs(prs ...api.PullRequest) {
for _, pr := range prs {
prNumber := fmt.Sprintf("#%d", pr.Number)
fmt.Printf(" %s %s %s", utils.Yellow(prNumber), truncate(50, pr.Title), utils.Cyan("["+pr.HeadRefName+"]"))
fmt.Printf(" %s %s %s", utils.Yellow(prNumber), truncate(50, pr.Title), utils.Cyan("["+pr.HeadLabel()+"]"))
checks := pr.ChecksStatus()
reviews := pr.ReviewStatus()

View file

@ -66,7 +66,7 @@ func TestPRList(t *testing.T) {
}
eq(t, out.String(), `32 New feature feature
29 Fixed bad bug bug-fix
29 Fixed bad bug hubot:bug-fix
28 Improve documentation docs
`)
}

View file

@ -16,7 +16,11 @@
"number": 29,
"title": "Fixed bad bug",
"url": "https://github.com/monalisa/hello/pull/29",
"headRefName": "bug-fix"
"headRefName": "bug-fix",
"isCrossRepository": true,
"headRepositoryOwner": {
"login": "hubot"
}
}
},
{