mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
feat: Add confirmation prompt and logic to comment and close duplicate issues
This commit is contained in:
parent
7dd0a0f348
commit
c111e7a30e
1 changed files with 30 additions and 0 deletions
|
@ -62,6 +62,23 @@ def find_oldest_issue(subject, all_issues):
|
||||||
return oldest_issue
|
return oldest_issue
|
||||||
|
|
||||||
|
|
||||||
|
def comment_and_close_duplicate(issue, oldest_issue):
|
||||||
|
comment_url = f"{GITHUB_API_URL}/repos/{REPO_OWNER}/{REPO_NAME}/issues/{issue['number']}/comments"
|
||||||
|
close_url = f"{GITHUB_API_URL}/repos/{REPO_OWNER}/{REPO_NAME}/issues/{issue['number']}"
|
||||||
|
|
||||||
|
comment_body = f"This looks like a duplicate of #{oldest_issue['number']}, so I'm going to close it so discussion can happen there. Please let me know if you think it's actually a distinct issue."
|
||||||
|
|
||||||
|
# Post comment
|
||||||
|
response = requests.post(comment_url, headers=headers, json={"body": comment_body})
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
# Close issue
|
||||||
|
response = requests.patch(close_url, headers=headers, json={"state": "closed"})
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
print(f" - Commented and closed issue #{issue['number']}")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if not TOKEN:
|
if not TOKEN:
|
||||||
print("Error: Missing GITHUB_TOKEN environment variable. Please check your .env file.")
|
print("Error: Missing GITHUB_TOKEN environment variable. Please check your .env file.")
|
||||||
|
@ -93,6 +110,19 @@ def main():
|
||||||
f" {oldest_issue['created_at']})"
|
f" {oldest_issue['created_at']})"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Confirmation prompt
|
||||||
|
confirm = input("Do you want to comment and close duplicate issues? (y/n): ")
|
||||||
|
if confirm.lower() != 'y':
|
||||||
|
print("Skipping this group of issues.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Comment and close duplicate issues
|
||||||
|
for issue in issues:
|
||||||
|
if issue['number'] != oldest_issue['number']:
|
||||||
|
comment_and_close_duplicate(issue, oldest_issue)
|
||||||
|
|
||||||
|
print(f"Oldest issue #{oldest_issue['number']} left open")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue