Skip to content

Commit

Permalink
Audit: Also close the pull request and delete the branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Aug 6, 2024
1 parent 7dc7430 commit 86c4f55
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions github_app_geo_project/module/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,19 @@ async def create_commit_pull_request(
return create_pull_request(branch, new_branch, message, body, project)


def close_pull_request_issues(message: str, project: configuration.GithubProject) -> None:
def close_pull_request_issues(new_branch: str, message: str, project: configuration.GithubProject) -> None:
"""
Close the pull request issues.
Close the pull request, issue and delete the branch.
If the pull request is open for 5 days, create an issue.
The 'Pull request is open for 5 days' issue.
"""
pulls = project.repo.get_pulls(state="open", head=f"{project.repo.full_name.split('/')[0]}:{new_branch}")
if pulls.totalCount > 0:
pull_request = pulls[0]
pull_request.edit(state="closed")

project.repo.get_git_ref(f"heads/{new_branch}").delete()

title = f"Pull request {message} is open for 5 days"
issues = project.repo.get_issues(
state="open", creator=project.application.integration.get_app().slug + "[bot]" # type: ignore[arg-type]
Expand Down

0 comments on commit 86c4f55

Please sign in to comment.