Skip to content

Commit 1552f70

Browse files
committed
remove auto-close and add contribution guide.
1 parent 347629a commit 1552f70

1 file changed

Lines changed: 13 additions & 26 deletions

File tree

utils/remind_link_issue.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
"""
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.
1616
1717
Behavior:
1818
- Scans open, non-draft PRs.
1919
- A PR is considered "linked" if GitHub's GraphQL `closingIssuesReferences` returns > 0
2020
(covers both `Fixes #N` keywords in the body and issues linked via the GitHub UI).
2121
- 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.
2322
- PRs labeled `no-issue-needed` and bot-authored PRs are skipped.
2423
"""
2524

@@ -32,10 +31,10 @@
3231

3332
REPO = "huggingface/diffusers"
3433
REMINDER_MARKER = "<!-- pr-link-issue-reminder -->"
35-
CLOSE_MARKER = "<!-- pr-link-issue-close -->"
3634
REMINDER_INTERVAL = timedelta(days=7)
3735
MAX_REMINDERS = 3
3836
BYPASS_LABELS = {"no-issue-needed"}
37+
CONTRIBUTION_GUIDE_URL = "https://huggingface.co/docs/diffusers/main/en/conceptual/contribution#coding-with-ai-agents"
3938

4039
GRAPHQL_URL = "https://api.github.com/graphql"
4140
GRAPHQL_QUERY = """
@@ -75,36 +74,25 @@ def reminder_body(author, count):
7574
REMINDER_MARKER,
7675
f"Hi @{author}, this PR does not appear to link an issue it fixes. "
7776
"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.",
7979
"",
80-
f"Reminder **{count}/{MAX_REMINDERS}**. ",
80+
f"Reminder **{count}/{MAX_REMINDERS}**.",
8181
]
8282
if remaining > 0:
8383
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, "
8585
f"you will receive {remaining} more reminder(s)."
8686
)
8787
else:
8888
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."
9392
)
9493
return "\n".join(lines)
9594

9695

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-
10896
def aware(ts):
10997
return ts if ts.tzinfo is not None else ts.replace(tzinfo=timezone.utc)
11098

@@ -138,14 +126,13 @@ def main():
138126
pr.create_issue_comment(reminder_body(author, 1))
139127
continue
140128

129+
if count >= MAX_REMINDERS:
130+
continue
131+
141132
if now - aware(reminders[-1].created_at) < REMINDER_INTERVAL:
142133
continue
143134

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))
149136

150137

151138
if __name__ == "__main__":

0 commit comments

Comments
 (0)