Skip to content

Make reassign reviewer only work for core contributors #13361

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

Merged
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
15 changes: 11 additions & 4 deletions .ci/magician/cmd/reassign_reviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ var reassignReviewerCmd = &cobra.Command{

The command expects the following PR details as arguments:
1. PR_NUMBER
2. REVIEWER (optional)
2. COMMENT_AUTHOR
3. REVIEWER (optional)


It then performs the following operations:
1. Updates the reviewer comment to reflect the new primary reviewer.
2. Requests a review from the new primary reviewer.
`,
Args: cobra.MinimumNArgs(1),
Args: cobra.MinimumNArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
prNumber := args[0]
fmt.Println("PR Number: ", prNumber)
Expand All @@ -49,9 +50,15 @@ var reassignReviewerCmd = &cobra.Command{
return fmt.Errorf("did not provide GITHUB_TOKEN environment variable")
}
gh := github.NewClient(githubToken)

author := args[1]
if gh.GetUserType(author) != github.CoreContributorUserType {
return fmt.Errorf("comment author is not a core contributor")
}

var newPrimaryReviewer string
if len(args) > 1 {
newPrimaryReviewer = args[1]
if len(args) > 2 {
newPrimaryReviewer = args[2]
}
return execReassignReviewer(prNumber, newPrimaryReviewer, gh)
},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reassign-reviewer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
go build .
- name: Run command
if: steps.read-comment.outputs.match != ''
run: .ci/magician/magician reassign-reviewer ${{ github.event.issue.number }} ${{ steps.read-comment.outputs.group1 }}
run: .ci/magician/magician reassign-reviewer ${{ github.event.issue.number }} ${{ github.event.comment.user.login }} ${{ steps.read-comment.outputs.group1 }}
Loading