Skip to content

Commit dccc6fc

Browse files
trodgeyerniyazN
authored andcommitted
Make reassign reviewer only work for core contributors (GoogleCloudPlatform#13361)
1 parent 19edf38 commit dccc6fc

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.ci/magician/cmd/reassign_reviewer.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ var reassignReviewerCmd = &cobra.Command{
3232
3333
The command expects the following PR details as arguments:
3434
1. PR_NUMBER
35-
2. REVIEWER (optional)
35+
2. COMMENT_AUTHOR
36+
3. REVIEWER (optional)
3637
3738
3839
It then performs the following operations:
3940
1. Updates the reviewer comment to reflect the new primary reviewer.
4041
2. Requests a review from the new primary reviewer.
4142
`,
42-
Args: cobra.MinimumNArgs(1),
43+
Args: cobra.MinimumNArgs(2),
4344
RunE: func(cmd *cobra.Command, args []string) error {
4445
prNumber := args[0]
4546
fmt.Println("PR Number: ", prNumber)
@@ -49,9 +50,15 @@ var reassignReviewerCmd = &cobra.Command{
4950
return fmt.Errorf("did not provide GITHUB_TOKEN environment variable")
5051
}
5152
gh := github.NewClient(githubToken)
53+
54+
author := args[1]
55+
if gh.GetUserType(author) != github.CoreContributorUserType {
56+
return fmt.Errorf("comment author is not a core contributor")
57+
}
58+
5259
var newPrimaryReviewer string
53-
if len(args) > 1 {
54-
newPrimaryReviewer = args[1]
60+
if len(args) > 2 {
61+
newPrimaryReviewer = args[2]
5562
}
5663
return execReassignReviewer(prNumber, newPrimaryReviewer, gh)
5764
},

.github/workflows/reassign-reviewer.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
go build .
4343
- name: Run command
4444
if: steps.read-comment.outputs.match != ''
45-
run: .ci/magician/magician reassign-reviewer ${{ github.event.issue.number }} ${{ steps.read-comment.outputs.group1 }}
45+
run: .ci/magician/magician reassign-reviewer ${{ github.event.issue.number }} ${{ github.event.comment.user.login }} ${{ steps.read-comment.outputs.group1 }}

0 commit comments

Comments
 (0)