Last active
August 19, 2021 21:40
-
-
Save jezdez/1e641842e2d901c4411af42967091376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A quick script to update the GitHub issue comments for issues marked as stale | |
with a fixed comment body after I found out that in YAML > doesn't mean | | |
(drops newlines). | |
More info: https://yaml-multiline.info | |
This requires PyGitHub: https://github.com/PyGithub/PyGithub | |
And of course a GitHub personal access token with repo scope | |
in the GITHUB_PERSONAL_ACCESS_TOKEN environment variable. | |
https://github.com/conda/conda/commit/cf9b4f18db3e4c395214f4d85812a26e50af525f fixed the config. | |
""" | |
import os | |
from github import Github | |
github = Github(os.environ['GITHUB_PERSONAL_ACCESS_TOKEN']) | |
repo = github.get_repo("conda/conda") | |
issues = repo.get_issues(state='open', labels=["stale-marked"]) | |
start = "Hi there, thank you for your contribution to Conda!" | |
# the fixed comment body | |
new_body = "Hi there, thank you for your contribution to Conda!\n\nThis issue has been **automatically marked as stale** because it has not had recent activity. It will be closed automatically if no further activity occurs.\n\nIf you would like this issue to remain open please:\n\n1. Verify that you can still reproduce the issue in the latest version of Conda\n2. Comment that the issue is still reproducible and include:\n\n - What version of Conda you reproduced the issue on\n - What OS and version you reproduced the issue on\n - What steps you followed to reproduce the issue\n\n3. It would also be helpful to have the output of the following commands available:\n\n - `conda info`\n - `conda config --show-sources`\n - `conda list --show-channel-urls`\n\n**NOTE:** If this issue was closed prematurely, please leave a comment and we will gladly reopen the issue.\n\nIn case this issue was originally about a project that is covered by the [Anaconda issue tracker](https://github.com/ContinuumIO/anaconda-issues/issues) (e.g. Anaconda, Miniconda, packages built by Anaconda, Inc. like Anaconda Navigator etc), please reopen the issue there again.\n\nThanks!\n" | |
comments = [] | |
for issue in issues: | |
for comment in issue.get_comments(): | |
if not comment.body.startswith(start): | |
continue | |
print(comment) | |
comments.append(comment) | |
comment.edit(new_body) | |
print(len(comments)) | |
print(comments) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment