-
Notifications
You must be signed in to change notification settings - Fork 798
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
Repo Gardening: check if PR owner is a member of the org to determine if they're an OSS Citizen #36860
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. |
4fe6b90
to
8fa160c
Compare
// Check if PR author is org member | ||
// https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#check-organization-membership-for-a-user | ||
const orgMembershipRequest = await octokit.rest.orgs.checkMembershipForUser( { | ||
org: owner.login, | ||
username: head.user.login, | ||
} ); | ||
|
||
if ( head.repo.full_name === base.repo.full_name || 204 === orgMembershipRequest.status ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, that would be a good addition I think.
That said, I wonder if we could save an API call in most scenarios, by keeping the 2 checks separate?
- We would start by checking if the PR is from a branch in the same remote, like we do today. If yes we bail, like today.
- Then, only when the PR is from a different remote we make the API call you're introducing here to figure out if the PR author is a member of the organization.
I believe it would avoid slowing things down for most of the PRs today.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Applied on 703a0b0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. 🚢
Proposed changes:
In some cases, PR authors within an organization might create a PR from a fork, in which case they will be mislabeled as an OSS Citizen. Here I propose an additional check for the PR Author's membership to the repo's organization.
Example of this occurring: Automattic/themes#7734 — The PR Author is a member of Automattic, but created a PR from a fork.
Other information:
Testing instructions:
Does this pull request change what data or activity we track or use?
No.