| | import os |
| | import re |
| | from github import Github |
| |
|
| | |
| | token = os.environ['GITHUB_TOKEN'] |
| | g = Github(token) |
| |
|
| | |
| | print(f"Repo is {os.environ['GITHUB_REPOSITORY']}") |
| | repo = g.get_repo(os.environ['GITHUB_REPOSITORY']) |
| |
|
| | |
| | |
| |
|
| | for issue in repo.get_issues(): |
| | print(f"Processing issue №{issue.number}") |
| | if issue.pull_request: |
| | continue |
| |
|
| | |
| | |
| |
|
| | |
| | keywords = ['Python', 'Commit hash', 'Launching Web UI with arguments', 'Model loaded', 'deforum'] |
| |
|
| | |
| | def check_keywords(issue_body, keywords): |
| | for keyword in keywords: |
| | if not re.search(r'\b' + re.escape(keyword) + r'\b', issue_body, re.IGNORECASE): |
| | return False |
| | return True |
| |
|
| | |
| | def check_title_word_count(issue_title, min_word_count): |
| | words = issue_title.replace("/", " ").replace("\\\\", " ").split() |
| | return len(words) >= min_word_count |
| |
|
| | |
| | def check_title_concise(issue_title, max_word_count): |
| | words = issue_title.replace("/", " ").replace("\\\\", " ").split() |
| | return len(words) <= max_word_count |
| |
|
| | |
| | def check_commit_id_format(issue_body): |
| | match = re.search(r'webui commit id - ([a-fA-F0-9]+|\[[a-fA-F0-9]+\])', issue_body) |
| | if not match: |
| | print('webui_commit_id not found') |
| | return False |
| | webui_commit_id = match.group(1) |
| | print(f'webui_commit_id {webui_commit_id}') |
| | webui_commit_id = webui_commit_id.replace("[", "").replace("]", "") |
| | if not (7 <= len(webui_commit_id) <= 40): |
| | print(f'invalid length!') |
| | return False |
| | match = re.search(r'deforum exten commit id - ([a-fA-F0-9]+|\[[a-fA-F0-9]+\])', issue_body) |
| | if match: |
| | print('deforum commit id not found') |
| | return False |
| | t2v_commit_id = match.group(1) |
| | print(f'deforum_commit_id {t2v_commit_id}') |
| | t2v_commit_id = t2v_commit_id.replace("[", "").replace("]", "") |
| | if not (7 <= len(t2v_commit_id) <= 40): |
| | print(f'invalid length!') |
| | return False |
| | return True |
| |
|
| | |
| | if '[Bug]' in issue.title and not '[Feature Request]' in issue.title: |
| | print('The issue is eligible') |
| | |
| | error_messages = [] |
| |
|
| | |
| | if not check_keywords(issue.body, keywords): |
| | error_messages.append("Include **THE FULL LOG FROM THE START OF THE WEBUI** in the issue description.") |
| |
|
| | if not check_title_word_count(issue.title, 3): |
| | error_messages.append("Make sure the issue title has at least 3 words.") |
| |
|
| | if not check_title_concise(issue.title, 13): |
| | error_messages.append("The issue title should be concise and contain no more than 13 words.") |
| |
|
| | |
| | |
| | |
| | |
| | if error_messages: |
| | print('Invalid issue, closing') |
| | |
| | not_planned_label = repo.get_label("wrong format") |
| | issue.add_to_labels(not_planned_label) |
| | |
| | |
| | issue.edit(state='closed') |
| | |
| | |
| | comment = "This issue has been closed due to incorrect formatting. Please address the following mistakes and reopen the issue (click on the 'Reopen' button below):\n\n" |
| | comment += "\n".join(f"- {error_message}" for error_message in error_messages) |
| |
|
| | |
| | issue.create_comment(comment) |
| | elif repo.get_label("wrong format") in issue.labels: |
| | print('Issue is fine') |
| | issue.edit(state='open') |
| | issue.delete_labels() |
| | bug_label = repo.get_label("bug") |
| | issue.add_to_labels(bug_label) |
| | comment = "Thanks for addressing your formatting mistakes. The issue has been reopened now." |
| | issue.create_comment(comment) |
| |
|