Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Commit

Permalink
alice: please: contribute: util: gh: Remove duplicate issue creation …
Browse files Browse the repository at this point in the history
…when searching only for issues created by logged in user

Introduced-in: 0ea349b
Signed-off-by: John Andersen <[email protected]>
  • Loading branch information
pdxjohnny committed Aug 18, 2023
1 parent 0ea349b commit 52db902
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions entities/alice/alice/please/contribute/util/gh.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async def gh_issue_search_by_title(
"--search",
title,
"--json",
"title,url,state,author,state",
"title,url,state,author,state,number",
],
logger=logger,
events=[dffml.Subprocess.STDOUT],
Expand All @@ -176,11 +176,17 @@ async def gh_issue_create_or_update_by_title(
# Try to find an exsiting issue with the same title
found_issue_to_update = None
found_issue_to_update_closed = None
async for issue in gh_issue_search_by_title(
repo_url,
title,
logger=logger,
):
# Sort issues in case we have duplicates
issues = [
issue
async for issue in gh_issue_search_by_title(
repo_url,
title,
logger=logger,
)
]
issues = list(sorted(issues, key=lambda issue: issue["number"], reverse=True))
for issue in issues:
if issue["author"]["login"] != auth_status.username:
continue
# TODO Data model from data model generation from schema
Expand All @@ -189,6 +195,7 @@ async def gh_issue_create_or_update_by_title(
found_issue_to_update = issue
else:
found_issue_to_update_closed = issue
break
# If we don't find it, create it
if found_issue_to_update is None and found_issue_to_update_closed is None:
return await gh_issue_create(
Expand Down

0 comments on commit 52db902

Please sign in to comment.