mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-16 19:18:24 +06:00
Fix stale bot for locked issues (#26711)
This commit is contained in:
parent
69873d529d
commit
6ecb2ab679
@ -18,6 +18,7 @@ https://github.com/allenai/allennlp.
|
|||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import github.GithubException
|
||||||
from github import Github
|
from github import Github
|
||||||
|
|
||||||
|
|
||||||
@ -36,8 +37,8 @@ def main():
|
|||||||
repo = g.get_repo("huggingface/transformers")
|
repo = g.get_repo("huggingface/transformers")
|
||||||
open_issues = repo.get_issues(state="open")
|
open_issues = repo.get_issues(state="open")
|
||||||
|
|
||||||
for issue in open_issues:
|
for i, issue in enumerate(open_issues):
|
||||||
print(issue)
|
print(i, issue)
|
||||||
comments = sorted([comment for comment in issue.get_comments()], key=lambda i: i.created_at, reverse=True)
|
comments = sorted([comment for comment in issue.get_comments()], key=lambda i: i.created_at, reverse=True)
|
||||||
last_comment = comments[0] if len(comments) > 0 else None
|
last_comment = comments[0] if len(comments) > 0 else None
|
||||||
if (
|
if (
|
||||||
@ -47,13 +48,17 @@ def main():
|
|||||||
and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
|
and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
|
||||||
):
|
):
|
||||||
# print(f"Would close issue {issue.number} since it has been 7 days of inactivity since bot mention.")
|
# print(f"Would close issue {issue.number} since it has been 7 days of inactivity since bot mention.")
|
||||||
|
try:
|
||||||
issue.edit(state="closed")
|
issue.edit(state="closed")
|
||||||
|
except github.GithubException as e:
|
||||||
|
print("Couldn't close the issue:", repr(e))
|
||||||
elif (
|
elif (
|
||||||
(dt.utcnow() - issue.updated_at.replace(tzinfo=None)).days > 23
|
(dt.utcnow() - issue.updated_at.replace(tzinfo=None)).days > 23
|
||||||
and (dt.utcnow() - issue.created_at.replace(tzinfo=None)).days >= 30
|
and (dt.utcnow() - issue.created_at.replace(tzinfo=None)).days >= 30
|
||||||
and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
|
and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
|
||||||
):
|
):
|
||||||
# print(f"Would add stale comment to {issue.number}")
|
# print(f"Would add stale comment to {issue.number}")
|
||||||
|
try:
|
||||||
issue.create_comment(
|
issue.create_comment(
|
||||||
"This issue has been automatically marked as stale because it has not had "
|
"This issue has been automatically marked as stale because it has not had "
|
||||||
"recent activity. If you think this still needs to be addressed "
|
"recent activity. If you think this still needs to be addressed "
|
||||||
@ -61,6 +66,8 @@ def main():
|
|||||||
"[contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) "
|
"[contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) "
|
||||||
"are likely to be ignored."
|
"are likely to be ignored."
|
||||||
)
|
)
|
||||||
|
except github.GithubException as e:
|
||||||
|
print("Couldn't create comment:", repr(e))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user