mirror of
https://github.com/huggingface/diffusers.git
synced 2026-10-23 09:09:01 +03:00
Do not count issues the PR author opened after the PR as linked
Applies to both the fixes-issue label and the issue-link reminder. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
12
.github/workflows/pr_labeler.yml
vendored
12
.github/workflows/pr_labeler.yml
vendored
@@ -52,6 +52,7 @@ jobs:
|
||||
|
||||
# fixes-issue
|
||||
- name: Check for linked closing issues
|
||||
# An issue the PR author opened after the PR does not count as linked.
|
||||
if: ${{ !cancelled() }}
|
||||
run: |
|
||||
OWNER="${REPO%/*}"
|
||||
@@ -62,13 +63,18 @@ jobs:
|
||||
query($owner: String!, $name: String!, $number: Int!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
pullRequest(number: $number) {
|
||||
closingIssuesReferences(first: 1) {
|
||||
totalCount
|
||||
createdAt
|
||||
author { login }
|
||||
closingIssuesReferences(first: 50) {
|
||||
nodes { createdAt author { login } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}' \
|
||||
--jq '.data.repository.pullRequest.closingIssuesReferences.totalCount')
|
||||
--jq '.data.repository.pullRequest as $pr
|
||||
| [$pr.closingIssuesReferences.nodes[]
|
||||
| select(.author.login != $pr.author.login or .createdAt < $pr.createdAt)]
|
||||
| length')
|
||||
HAS_LABEL=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq 'any(.[]; .name == "fixes-issue")')
|
||||
if [ "${COUNT:-0}" -gt 0 ]; then
|
||||
if [ "$HAS_LABEL" != "true" ]; then
|
||||
|
||||
@@ -16,8 +16,9 @@ Script to remind PR authors to link an issue, and to escalate unresolved reminde
|
||||
|
||||
Behavior:
|
||||
- Scans open, non-draft PRs.
|
||||
- A PR is considered "linked" if GitHub's GraphQL `closingIssuesReferences` returns > 0
|
||||
(covers both `Fixes #N` keywords in the body and issues linked via the GitHub UI).
|
||||
- A PR is considered "linked" if GitHub's GraphQL `closingIssuesReferences` returns an
|
||||
issue (covers both `Fixes #N` keywords in the body and issues linked via the GitHub UI),
|
||||
not counting issues the PR author opened after the PR.
|
||||
- If a PR is not linked and has no reminder yet, the script posts a single friendly
|
||||
reminder comment warning that the PR may be auto-closed.
|
||||
- If a PR only has an old-style reminder (posted before the auto-close notice existed),
|
||||
@@ -86,8 +87,13 @@ GRAPHQL_QUERY = """
|
||||
query($owner: String!, $name: String!, $number: Int!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
pullRequest(number: $number) {
|
||||
closingIssuesReferences(first: 1) {
|
||||
totalCount
|
||||
createdAt
|
||||
author { login }
|
||||
closingIssuesReferences(first: 50) {
|
||||
nodes {
|
||||
createdAt
|
||||
author { login }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,7 +113,12 @@ def has_linked_issue(token, owner, name, number):
|
||||
data = payload.get("data")
|
||||
if not data:
|
||||
return False
|
||||
return data["repository"]["pullRequest"]["closingIssuesReferences"]["totalCount"] > 0
|
||||
pr = data["repository"]["pullRequest"]
|
||||
pr_author = (pr["author"] or {}).get("login")
|
||||
return any(
|
||||
(issue["author"] or {}).get("login") != pr_author or issue["createdAt"] < pr["createdAt"]
|
||||
for issue in pr["closingIssuesReferences"]["nodes"]
|
||||
)
|
||||
|
||||
|
||||
def author_checkbox_checked(pr):
|
||||
|
||||
Reference in New Issue
Block a user