Skip to content

Commit

Permalink
fix(cloud): synced reviewers should be unique (#1377)
Browse files Browse the repository at this point in the history
<!--  Thanks for sending a pull request!  Here are some tips for you:

1. If this is your first time, please read our contributor guidelines:
https://github.com/terramate-io/terramate/blob/main/CONTRIBUTING.md
2. If the PR is unfinished, mark it as draft:
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request
3. Please update the PR title using the Conventional Commits convention:
https://www.conventionalcommits.org/en/v1.0.0/
    Example: feat: add support for XYZ.
-->

## What this PR does / why we need it:

Before, if the same user did multiple reviews, the synced reviewer list
would contain duplicates. This PR changes it so that each reviewer is
only included once.

## Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related
issues/tests in a comment and do not use `Fixes`_*
Keep it empty if not applicable.
-->

## Special notes for your reviewer:

## Does this PR introduce a user-facing change?
<!--
If no, just write "no" in the block below.
If yes, please explain the change and update documentation and the
CHANGELOG.md file accordingly.
-->
```
no
```
  • Loading branch information
snakster committed Jan 18, 2024
2 parents e200f18 + 5b20c59 commit 085518a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/terramate/cli/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,18 @@ func (c *cli) detectCloudMetadata() {
Msg("failed to retrieve PR reviews")
}

uniqueReviewers := make(map[string]struct{})

for _, review := range reviews {
login := review.User.Login

if _, found := uniqueReviewers[login]; found {
continue
}
uniqueReviewers[login] = struct{}{}

reviewRequest.Reviewers = append(reviewRequest.Reviewers, cloud.Reviewer{
Login: review.User.Login,
Login: login,
AvatarURL: review.User.AvatarURL,
})
}
Expand Down

0 comments on commit 085518a

Please sign in to comment.