Skip branch-PR validation in validate-pr-target-branch workflow#37988
Conversation
…ame repo) Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/efcore/sessions/9fa9efe5-51a7-419b-bc7a-79c97dd6778c
There was a problem hiding this comment.
Pull request overview
Updates the Validate PR Target Branch workflow to short-circuit validation for PRs originating from branches within the same repository, avoiding unnecessary permission checks for internal PRs while keeping fork-based PR validation intact.
Changes:
- Added an early return when
pr.head.repo.id === pr.base.repo.id(same-repo PR), skipping the collaborator permission API call and subsequent release-branch validation logic.
| } | ||
|
|
||
| // If the PR is from a branch (not a fork), it must be from an internal contributor | ||
| if (pr.head.repo && pr.head.repo.id === pr.base.repo.id) { |
There was a problem hiding this comment.
Looks reasonable overall, but shouldn't we just check directly if the PR author has write access? That seems more direct, and also I don't push my PR branches to EF - I push them to my fork just like any external contributor, and it would be good for those PRs to also get picked up as from an internal contributor.
There was a problem hiding this comment.
Looks reasonable overall, but shouldn't we just check directly if the PR author has write access? That seems more direct, and also I don't push my PR branches to EF - I push them to my fork just like any external contributor, and it would be good for those PRs to also get picked up as from an internal contributor.
We already check the access below. This is just a short-circuit optimization.
External contributors can only open PRs from forks, not branches. If a PR originates from a branch in the same repo (
head.repo.id === base.repo.id), it must be from an internal contributor — no permission API call or release-branch check needed.Change
This eliminates the
getCollaboratorPermissionLevelAPI call for all internal PRs and simplifies the execution path for the majority of PRs.