|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 | """ |
15 | | -Script to remind PR authors to link an issue, and close PRs that ignore the reminders. |
| 15 | +Script to remind PR authors to link an issue. |
16 | 16 |
|
17 | 17 | Behavior: |
18 | 18 | - Scans open, non-draft PRs. |
19 | 19 | - A PR is considered "linked" if GitHub's GraphQL `closingIssuesReferences` returns > 0 |
20 | 20 | (covers both `Fixes #N` keywords in the body and issues linked via the GitHub UI). |
21 | 21 | - If a PR is not linked, the script posts up to 3 reminder comments spaced 7 days apart. |
22 | | -- If the 3rd reminder is older than 7 days and the PR is still not linked, the PR is closed. |
23 | 22 | - PRs labeled `no-issue-needed` and bot-authored PRs are skipped. |
24 | 23 | """ |
25 | 24 |
|
|
32 | 31 |
|
33 | 32 | REPO = "huggingface/diffusers" |
34 | 33 | REMINDER_MARKER = "<!-- pr-link-issue-reminder -->" |
35 | | -CLOSE_MARKER = "<!-- pr-link-issue-close -->" |
36 | 34 | REMINDER_INTERVAL = timedelta(days=7) |
37 | 35 | MAX_REMINDERS = 3 |
38 | 36 | BYPASS_LABELS = {"no-issue-needed"} |
| 37 | +CONTRIBUTION_GUIDE_URL = "https://huggingface.co/docs/diffusers/main/en/conceptual/contribution#coding-with-ai-agents" |
39 | 38 |
|
40 | 39 | GRAPHQL_URL = "https://api.github.com/graphql" |
41 | 40 | GRAPHQL_QUERY = """ |
@@ -75,36 +74,25 @@ def reminder_body(author, count): |
75 | 74 | REMINDER_MARKER, |
76 | 75 | f"Hi @{author}, this PR does not appear to link an issue it fixes. " |
77 | 76 | "If this PR addresses an existing issue, please add a closing keyword " |
78 | | - "(e.g. `Fixes #1234`) to the PR description so the issue is linked.", |
| 77 | + "(e.g. `Fixes #1234`) to the PR description so the issue is linked. " |
| 78 | + f"See the [contribution guide]({CONTRIBUTION_GUIDE_URL}) for more details.", |
79 | 79 | "", |
80 | | - f"Reminder **{count}/{MAX_REMINDERS}**. ", |
| 80 | + f"Reminder **{count}/{MAX_REMINDERS}**.", |
81 | 81 | ] |
82 | 82 | if remaining > 0: |
83 | 83 | lines[-1] += ( |
84 | | - f"If no linked issue is added within {REMINDER_INTERVAL.days} days, " |
| 84 | + f" If no linked issue is added within {REMINDER_INTERVAL.days} days, " |
85 | 85 | f"you will receive {remaining} more reminder(s)." |
86 | 86 | ) |
87 | 87 | else: |
88 | 88 | lines[-1] += ( |
89 | | - f"This is the final reminder. If no linked issue is added within " |
90 | | - f"{REMINDER_INTERVAL.days} days, this PR will be closed automatically. " |
91 | | - "If this PR intentionally does not fix a tracked issue, a maintainer " |
92 | | - "can add the `no-issue-needed` label to bypass this check." |
| 89 | + " This is the final reminder. If this PR intentionally does not fix " |
| 90 | + "a tracked issue, a maintainer can add the `no-issue-needed` label " |
| 91 | + "to bypass this check." |
93 | 92 | ) |
94 | 93 | return "\n".join(lines) |
95 | 94 |
|
96 | 95 |
|
97 | | -def close_body(author): |
98 | | - return ( |
99 | | - f"{CLOSE_MARKER}\n" |
100 | | - f"Closing this PR because @{author} did not add a linked issue after " |
101 | | - f"{MAX_REMINDERS} reminders spaced {REMINDER_INTERVAL.days} days apart. " |
102 | | - "Please reopen once the PR description references the issue it fixes " |
103 | | - "(e.g. `Fixes #1234`), or ask a maintainer to add the `no-issue-needed` " |
104 | | - "label if this PR is intentionally unrelated to a tracked issue." |
105 | | - ) |
106 | | - |
107 | | - |
108 | 96 | def aware(ts): |
109 | 97 | return ts if ts.tzinfo is not None else ts.replace(tzinfo=timezone.utc) |
110 | 98 |
|
@@ -138,14 +126,13 @@ def main(): |
138 | 126 | pr.create_issue_comment(reminder_body(author, 1)) |
139 | 127 | continue |
140 | 128 |
|
| 129 | + if count >= MAX_REMINDERS: |
| 130 | + continue |
| 131 | + |
141 | 132 | if now - aware(reminders[-1].created_at) < REMINDER_INTERVAL: |
142 | 133 | continue |
143 | 134 |
|
144 | | - if count >= MAX_REMINDERS: |
145 | | - pr.create_issue_comment(close_body(author)) |
146 | | - pr.edit(state="closed") |
147 | | - else: |
148 | | - pr.create_issue_comment(reminder_body(author, count + 1)) |
| 135 | + pr.create_issue_comment(reminder_body(author, count + 1)) |
149 | 136 |
|
150 | 137 |
|
151 | 138 | if __name__ == "__main__": |
|
0 commit comments