mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 20:35:00 +00:00
refactor: extract issue handling into dedicated functions
This commit is contained in:
parent
e8c153f72f
commit
17351e8f91
1 changed files with 45 additions and 43 deletions
|
@ -130,26 +130,7 @@ def find_unlabeled_with_paul_comments(issues):
|
||||||
return unlabeled_issues
|
return unlabeled_issues
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def handle_unlabeled_issues(all_issues, auto_yes):
|
||||||
parser = argparse.ArgumentParser(description="Handle duplicate GitHub issues")
|
|
||||||
parser.add_argument(
|
|
||||||
"--yes", action="store_true", help="Automatically close duplicates without prompting"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--find-unlabeled",
|
|
||||||
action="store_true",
|
|
||||||
help="Find unlabeled issues with paul-gauthier comments",
|
|
||||||
)
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
if not TOKEN:
|
|
||||||
print("Error: Missing GITHUB_TOKEN environment variable. Please check your .env file.")
|
|
||||||
return
|
|
||||||
|
|
||||||
all_issues = get_issues("all")
|
|
||||||
|
|
||||||
if args.find_unlabeled:
|
|
||||||
#ai refactor this into a function...
|
|
||||||
print("\nFinding unlabeled issues with paul-gauthier comments...")
|
print("\nFinding unlabeled issues with paul-gauthier comments...")
|
||||||
unlabeled_issues = find_unlabeled_with_paul_comments(all_issues)
|
unlabeled_issues = find_unlabeled_with_paul_comments(all_issues)
|
||||||
|
|
||||||
|
@ -161,7 +142,7 @@ def main():
|
||||||
for issue in unlabeled_issues:
|
for issue in unlabeled_issues:
|
||||||
print(f" - #{issue['number']}: {issue['title']} {issue['html_url']}")
|
print(f" - #{issue['number']}: {issue['title']} {issue['html_url']}")
|
||||||
|
|
||||||
if not args.yes:
|
if not auto_yes:
|
||||||
confirm = input("\nDo you want to add the 'question' label to these issues? (y/n): ")
|
confirm = input("\nDo you want to add the 'question' label to these issues? (y/n): ")
|
||||||
if confirm.lower() != "y":
|
if confirm.lower() != "y":
|
||||||
print("Skipping labeling.")
|
print("Skipping labeling.")
|
||||||
|
@ -173,10 +154,9 @@ def main():
|
||||||
response = requests.patch(url, headers=headers, json={"labels": ["question"]})
|
response = requests.patch(url, headers=headers, json={"labels": ["question"]})
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
print(f" - Added 'question' label to #{issue['number']}")
|
print(f" - Added 'question' label to #{issue['number']}")
|
||||||
return
|
|
||||||
# ... to here
|
|
||||||
|
|
||||||
# ai also refactor this into its own function...
|
|
||||||
|
def handle_duplicate_issues(all_issues, auto_yes):
|
||||||
open_issues = [issue for issue in all_issues if issue["state"] == "open"]
|
open_issues = [issue for issue in all_issues if issue["state"] == "open"]
|
||||||
grouped_open_issues = group_issues_by_subject(open_issues)
|
grouped_open_issues = group_issues_by_subject(open_issues)
|
||||||
|
|
||||||
|
@ -202,21 +182,43 @@ def main():
|
||||||
f" {oldest_issue['html_url']} ({oldest_issue['state']})"
|
f" {oldest_issue['html_url']} ({oldest_issue['state']})"
|
||||||
)
|
)
|
||||||
|
|
||||||
if not args.yes:
|
if not auto_yes:
|
||||||
# Confirmation prompt
|
|
||||||
confirm = input("Do you want to comment and close duplicate issues? (y/n): ")
|
confirm = input("Do you want to comment and close duplicate issues? (y/n): ")
|
||||||
if confirm.lower() != "y":
|
if confirm.lower() != "y":
|
||||||
print("Skipping this group of issues.")
|
print("Skipping this group of issues.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Comment and close duplicate issues
|
|
||||||
for issue in issues:
|
for issue in issues:
|
||||||
if issue["number"] != oldest_issue["number"]:
|
if issue["number"] != oldest_issue["number"]:
|
||||||
comment_and_close_duplicate(issue, oldest_issue)
|
comment_and_close_duplicate(issue, oldest_issue)
|
||||||
|
|
||||||
if oldest_issue["state"] == "open":
|
if oldest_issue["state"] == "open":
|
||||||
print(f"Oldest issue #{oldest_issue['number']} left open")
|
print(f"Oldest issue #{oldest_issue['number']} left open")
|
||||||
# ai ... to here!
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="Handle duplicate GitHub issues")
|
||||||
|
parser.add_argument(
|
||||||
|
"--yes", action="store_true", help="Automatically close duplicates without prompting"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--find-unlabeled",
|
||||||
|
action="store_true",
|
||||||
|
help="Find unlabeled issues with paul-gauthier comments",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if not TOKEN:
|
||||||
|
print("Error: Missing GITHUB_TOKEN environment variable. Please check your .env file.")
|
||||||
|
return
|
||||||
|
|
||||||
|
all_issues = get_issues("all")
|
||||||
|
|
||||||
|
if args.find_unlabeled:
|
||||||
|
handle_unlabeled_issues(all_issues, args.yes)
|
||||||
|
return
|
||||||
|
|
||||||
|
handle_duplicate_issues(all_issues, args.yes)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue