This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
Add relevant reviewers to PRs to local BitBucket repositories instead of everyone in the Project #1108
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Bug fix? I guess?
When creating a PR to a locally-hosted BitBucket repository everyone set as a default reviewer in the Project, including users that no longer exist, are added as reviewers.
This results in people who don't need to see the PRs being added to them erroneously.
Also, default reviewer rules are not respected, so folks that should be put on PRs are not added.
If a user no longer exists NuKeeper fails due to the presence of an error section in the response, even though BitBucket also provides a list of users.
For reference, repositories live inside of projects in BB, so we might have:
Project X
If Project X has reviewers:
A: All branches
B: Branches named "foo-"
C: Branches named "bar-"
Repo:
D: "foo-*"
Example cases:
PR of branch "abc" into Repo:
Users A, B, and C will be added to the PR but user D will not be.
Expected behavior in that case would be for user A to be added and no one else.
PR of branch "foo-123" into Repo:
Users A, B, and C will be added to the PR but user D will not be.
Expected behavior: Users A, B, and D are added.
PR of branch "bar-456" into Repo:
Users A, B, and C will be added to the PR but user D will not be.
Expected behavior: Users A and B are added.
🆕 What is the new behavior (if this is a feature change)?
Call the default reviewers API on the BitBucket instance to get the list of expected reviewers from BitBucket itself and filter out any inactive (aka: deleted) users that might have been left in rules on the server. BitBucket will apply the rules that would be applied if a user had created the PR manually.
💥 Does this PR introduce a breaking change?
Yes, but the existing behavior was likely not what was intended
🐛 Recommendations for testing
See above example cases, also test with users that have been removed from BitBucket but are still present in default reviewer rules.
📝 Links to relevant issues/docs
N/A
🤔 Checklist before submitting