Support ghost reviews in pr view
This commit is contained in:
parent
d70358ea34
commit
67907c8b00
3 changed files with 15 additions and 3 deletions
|
|
@ -434,14 +434,20 @@ func prReviewerList(pr api.PullRequest) string {
|
|||
// Ref. https://developer.github.com/v4/union/requestedreviewer/
|
||||
const teamTypeName = "Team"
|
||||
|
||||
const ghostName = "ghost"
|
||||
|
||||
// parseReviewers parses given Reviews and ReviewRequests
|
||||
func parseReviewers(pr api.PullRequest) []*reviewerState {
|
||||
reviewerStates := make(map[string]*reviewerState)
|
||||
|
||||
for _, review := range pr.Reviews.Nodes {
|
||||
if review.Author.Login != pr.Author.Login {
|
||||
reviewerStates[review.Author.Login] = &reviewerState{
|
||||
Name: review.Author.Login,
|
||||
name := review.Author.Login
|
||||
if name == "" {
|
||||
name = ghostName
|
||||
}
|
||||
reviewerStates[name] = &reviewerState{
|
||||
Name: name,
|
||||
State: review.State,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ func TestPRView_Preview(t *testing.T) {
|
|||
fixture: "../test/fixtures/prViewPreviewWithReviewersByNumber.json",
|
||||
expectedOutputs: []string{
|
||||
`Blueberries are from a fork`,
|
||||
`Reviewers: DEF \(Commented\), def \(Changes requested\), xyz \(Approved\), 123 \(Requested\), Team 1 \(Requested\), abc \(Requested\)\n`,
|
||||
`Reviewers: DEF \(Commented\), def \(Changes requested\), ghost \(Approved\), xyz \(Approved\), 123 \(Requested\), Team 1 \(Requested\), abc \(Requested\)\n`,
|
||||
`blueberries taste good`,
|
||||
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12\n`,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -64,6 +64,12 @@
|
|||
"login": "xyz"
|
||||
},
|
||||
"state": "APPROVED"
|
||||
},
|
||||
{
|
||||
"author": {
|
||||
"login": ""
|
||||
},
|
||||
"state": "APPROVED"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue