Skip to content

Commit

Permalink
Merge pull request #84 from garethjevans/review
Browse files Browse the repository at this point in the history
feat: show review status on 'get prs'
  • Loading branch information
cagiti authored Dec 8, 2020
2 parents a0a1f4c + a3b0ff4 commit 4639136
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
4 changes: 4 additions & 0 deletions pkg/cmd/common_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestCommonCmd_Filter_AllData(t *testing.T) {
"repository": {
"nameWithOwner": ""
},
"reviewDecision": "",
"title": "",
"url": ""
},
Expand All @@ -56,6 +57,7 @@ func TestCommonCmd_Filter_AllData(t *testing.T) {
"repository": {
"nameWithOwner": ""
},
"reviewDecision": "",
"title": "",
"url": ""
},
Expand All @@ -76,6 +78,7 @@ func TestCommonCmd_Filter_AllData(t *testing.T) {
"repository": {
"nameWithOwner": ""
},
"reviewDecision": "",
"title": "",
"url": ""
}
Expand Down Expand Up @@ -111,6 +114,7 @@ func TestCommonCmd_Filter_FilterOnAuthor(t *testing.T) {
"repository": {
"nameWithOwner": ""
},
"reviewDecision": "",
"title": "",
"url": ""
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/getcmd/get_prs.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (c *GetPrsCmd) Run() error {
"Author",
"Title",
"Age",
"Review",
"Labels",
"Mergeable",
)
Expand All @@ -111,6 +112,7 @@ func (c *GetPrsCmd) Run() error {
pr.Author.Login,
pr.ColoredTitle(),
util.SafeTime(&pr.CreatedAt),
pr.ColoredReviewDecision(),
pr.LabelsString(),
pr.MergeableString(),
)
Expand Down
1 change: 1 addition & 0 deletions pkg/domain/get_prs.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (g *GetPrs) Run() error {
name
}
}
reviewDecision
commits(last: 1){
nodes{
commit{
Expand Down
33 changes: 23 additions & 10 deletions pkg/pr/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ import (
)

type PullRequest struct {
Number int `json:"number"`
Title string `json:"title"`
URL string `json:"url"`
Mergeable string `json:"mergeable"`
CreatedAt time.Time `json:"createdAt"`
Author Author `json:"author"`
Labels Labels `json:"labels"`
Commits Commits `json:"commits"`
Closed bool `json:"closed"`
Repository Repository `json:"repository"`
Number int `json:"number"`
Title string `json:"title"`
URL string `json:"url"`
Mergeable string `json:"mergeable"`
CreatedAt time.Time `json:"createdAt"`
Author Author `json:"author"`
Labels Labels `json:"labels"`
Commits Commits `json:"commits"`
Closed bool `json:"closed"`
Repository Repository `json:"repository"`
ReviewDecision string `json:"reviewDecision"`
}

const (
Expand Down Expand Up @@ -112,6 +113,18 @@ func (p *PullRequest) ColoredTitle() string {
}
}

func (p *PullRequest) ColoredReviewDecision() string {
if p.ReviewDecision == "APPROVED" {
return util.ColorInfo("Approved")
} else if p.ReviewDecision == "REVIEW_REQUIRED" {
return util.ColorWarning("Required")
} else if p.ReviewDecision == "CHANGES_REQUESTED" {
return util.ColorError("Changes Requested")
} else {
return p.ReviewDecision
}
}

func (p *PullRequest) TrimmedTitle() string {
if len(p.Title) > 75 {
return fmt.Sprintf("%s...", p.Title[:75])
Expand Down

0 comments on commit 4639136

Please sign in to comment.