Filter PRs by user in isFirstPullRequest - #402
Conversation
The isFirstPullRequest function was checking ALL PRs in the repo instead of only the current user's PRs. This caused everyone to be identified as a new contributor in repos with issues disabled (since isFirstIssue returns true when no issues exist). Now isFirstPullRequest filters PRs by user login, matching the behavior of isFirstIssue. Closes actions#369 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
For issue events, only check isFirstIssue(). For PR events, only check isFirstPullRequest(). This fixes the case where repos with issues disabled would mark everyone as a new contributor (since isFirstIssue returns true when no issues exist). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Hi, just checking in on this PR—happy to make any changes or provide more context if helpful. |
|
Related: #410 |
|
@ncalteen Hiya, just checking in on this PR—happy to make any changes or provide more context if helpful. |
| // Check if this is the user's first contribution of the relevant type. | ||
| if (isIssue && !(await isFirstIssue(octokit))) | ||
| return core.info('Skipping...Not First Issue') | ||
| if (isPullRequest && !(await isFirstPullRequest(octokit))) | ||
| return core.info('Skipping...Not First Pull Request') |
There was a problem hiding this comment.
Checking typed contributions is a valid use case, but so is checking untyped contributions, I think. Maybe an issue comment should not be created if a user is familiar enough with the repository to have authored a PR.
In my opinion the name of the action first-interaction implies any contribution. The action could have subdirectories like actions/first-interaction/first-pr and actions/first-interaction/first-issue for checking specific types.
| // Check if this is the user's first contribution of the relevant type. | |
| if (isIssue && !(await isFirstIssue(octokit))) | |
| return core.info('Skipping...Not First Issue') | |
| if (isPullRequest && !(await isFirstPullRequest(octokit))) | |
| return core.info('Skipping...Not First Pull Request') | |
| // Check if this is the user's first contribution. | |
| if (!(await isFirstIssue(octokit) && await isFirstPullRequest(octokit))) | |
| return core.info('Skipping...Not First Contribution') |
Though, maybe clearer function names would be something like userHasAuthoredPullRequestsPreviously and userHasReportedIssuesPreviously.
Summary
isFirstPullRequest()to filter PRs by the current user's loginisFirstIssue()isFirstPullRequest()isFirstIssuereturns true when no issues exist)Test plan
Fixes #369.