Skip to content

Commit 2cad1a8

Browse files
yiyixuxuyiyixuxu
andauthored
[stalebot] don't close the issue if the stale label is removed (#7106)
* fix * fix * remove stalebot's ability to close issues --------- Co-authored-by: yiyixuxu <yixu310@gmail,com>
1 parent e6cf219 commit 2cad1a8

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

utils/stale.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,18 @@ def main():
3939
open_issues = repo.get_issues(state="open")
4040

4141
for issue in open_issues:
42-
comments = sorted(issue.get_comments(), key=lambda i: i.created_at, reverse=True)
43-
last_comment = comments[0] if len(comments) > 0 else None
44-
if (
45-
last_comment is not None
46-
and last_comment.user.login == "github-actions[bot]"
47-
and (dt.now(timezone.utc) - issue.updated_at).days > 7
48-
and (dt.now(timezone.utc) - issue.created_at).days >= 30
49-
and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
50-
):
51-
# Closes the issue after 7 days of inactivity since the Stalebot notification.
52-
issue.edit(state="closed")
53-
elif (
54-
"stale" in issue.get_labels()
55-
and last_comment is not None
56-
and last_comment.user.login != "github-actions[bot]"
57-
):
58-
# Opens the issue if someone other than Stalebot commented.
59-
issue.edit(state="open")
60-
issue.remove_from_labels("stale")
42+
labels = [label.name for label in issue.get_labels()]
43+
if "stale" in labels:
44+
comments = sorted(issue.get_comments(), key=lambda i: i.created_at, reverse=True)
45+
last_comment = comments[0] if len(comments) > 0 else None
46+
if last_comment is not None and last_comment.user.login != "github-actions[bot]":
47+
# Opens the issue if someone other than Stalebot commented.
48+
issue.edit(state="open")
49+
issue.remove_from_labels("stale")
6150
elif (
6251
(dt.now(timezone.utc) - issue.updated_at).days > 23
6352
and (dt.now(timezone.utc) - issue.created_at).days >= 30
64-
and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
53+
and not any(label.name.lower() in LABELS_TO_EXEMPT for label in labels)
6554
):
6655
# Post a Stalebot notification after 23 days of inactivity.
6756
issue.create_comment(

0 commit comments

Comments
 (0)