Print merged and closed PRs of the current branch along with an opening PR
This commit is contained in:
parent
8b31b283f5
commit
5f152a349d
2 changed files with 9 additions and 7 deletions
|
|
@ -10,7 +10,7 @@ import (
|
|||
type PullRequestsPayload struct {
|
||||
ViewerCreated PullRequestAndTotalCount
|
||||
ReviewRequested PullRequestAndTotalCount
|
||||
CurrentPR *PullRequest
|
||||
CurrentPRs []PullRequest
|
||||
}
|
||||
|
||||
type PullRequestAndTotalCount struct {
|
||||
|
|
@ -262,11 +262,13 @@ func PullRequests(client *Client, repo ghrepo.Interface, currentPRNumber int, cu
|
|||
reviewRequested = append(reviewRequested, edge.Node)
|
||||
}
|
||||
|
||||
var currentPR = resp.Repository.PullRequest
|
||||
if currentPR == nil {
|
||||
var currentPRs []PullRequest
|
||||
if resp.Repository.PullRequest != nil {
|
||||
currentPRs = append(currentPRs, *resp.Repository.PullRequest)
|
||||
} else {
|
||||
for _, edge := range resp.Repository.PullRequests.Edges {
|
||||
if edge.Node.HeadLabel() == currentPRHeadRef {
|
||||
currentPR = &edge.Node
|
||||
currentPRs = append(currentPRs, edge.Node)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -280,7 +282,7 @@ func PullRequests(client *Client, repo ghrepo.Interface, currentPRNumber int, cu
|
|||
PullRequests: reviewRequested,
|
||||
TotalCount: resp.ReviewRequested.TotalCount,
|
||||
},
|
||||
CurrentPR: currentPR,
|
||||
CurrentPRs: currentPRs,
|
||||
}
|
||||
|
||||
return &payload, nil
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ func prStatus(cmd *cobra.Command, args []string) error {
|
|||
fmt.Fprintln(out, "")
|
||||
|
||||
printHeader(out, "Current branch")
|
||||
if prPayload.CurrentPR != nil {
|
||||
printPrs(out, 0, *prPayload.CurrentPR)
|
||||
if prPayload.CurrentPRs != nil {
|
||||
printPrs(out, 0, prPayload.CurrentPRs...)
|
||||
} else {
|
||||
message := fmt.Sprintf(" There is no pull request associated with %s", utils.Cyan("["+currentPRHeadRef+"]"))
|
||||
printMessage(out, message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue