Skip to content

Commit

Permalink
Merge pull request #644 from fabinca/add-gitlab-reviewer
Browse files Browse the repository at this point in the history
Add gitlab reviewer
  • Loading branch information
brainexe authored Dec 19, 2024
2 parents a92cf2b + 044acf2 commit a5f7b57
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 9 additions & 3 deletions command/pullrequest/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ func (c *gitlabFetcher) getPullRequest(match matcher.Result) (pullRequest, error

func (c *gitlabFetcher) getStatus(pr *gitlab.MergeRequest) prStatus {
// https://docs.gitlab.com/ce/api/merge_requests.html
switch pr.State {
case "merged":
inReview := false
if len(pr.Reviewers) > 0 {
inReview = true
}
switch {
case pr.State == "merged":
return prStatusMerged
case "closed", "locked":
case pr.State == "closed" || pr.State == "locked":
return prStatusClosed
case inReview:
return prStatusInReview
default:
return prStatusOpen
}
Expand Down
9 changes: 9 additions & 0 deletions command/pullrequest/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ func TestGitlab(t *testing.T) {
mr.State = "closed"
actual = gitlabFetcher.getStatus(mr)
assert.Equal(t, prStatusClosed, actual)

mr = &gitlab.MergeRequest{}
mr.Reviewers = []*gitlab.BasicUser{
{
Username: "user",
},
}
actual = gitlabFetcher.getStatus(mr)
assert.Equal(t, prStatusInReview, actual)
})

t.Run("test convertToPullRequest", func(t *testing.T) {
Expand Down

0 comments on commit a5f7b57

Please sign in to comment.