Skip to content

Instantly share code, notes, and snippets.

@bilke
Created June 19, 2020 19:00
Show Gist options
  • Save bilke/ac6a40ca7f3fae159fda33c0a7a98232 to your computer and use it in GitHub Desktop.
Save bilke/ac6a40ca7f3fae159fda33c0a7a98232 to your computer and use it in GitHub Desktop.
Close all PRs and issues on GitHub and add commen
from github import Github, PullRequest
g = Github("[Personal Access Token]")
r = g.get_repo('ufz/ogs')
for issue in r.get_issues(state='all', direction='asc'):
comment_str = "OpenGeoSys development has been moved to [GitLab](https://gitlab.opengeosys.org/ogs/ogs).\n\n"
try:
pr = issue.as_pull_request()
except:
print(f"IS ISSUE: {issue.number}")
comment_str += f"[See this issue on GitLab](https://gitlab.opengeosys.org/ogs/ogs/-/issues/{issue.number})."
else:
print(f"IS PR: {pr.number}")
comment_str += f"[See this pull request on GitLab](https://gitlab.opengeosys.org/ogs/ogs/-/merge_requests/{pr.number})."
if issue.state != 'closed':
issue.edit(state='closed')
comment_str += f"\n\nThis issue / pull request was **open** before the GitLab migration."
issue.create_comment(comment_str)
print(comment_str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment