Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gitlab reviewer #644

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading