示例#1
0
文件: pr_monitor.py 项目: verult/Cirq
def edit_comment(repo: GithubRepository, text: str, comment_id: int) -> None:
    """Edits an existing github comment.

    References:
        https://developer.github.com/v3/issues/comments/#edit-a-comment

    Args:
        repo: The github repo that contains the comment.
        text: The new comment text.
        comment_id: The id of the comment to edit.

    Raises:
            RuntimeError: If the request does not return status 200 (success).
    """
    url = "https://api.github.com/repos/{}/{}/issues/comments/{}".format(
        repo.organization, repo.name, comment_id
    )
    data = {'body': text}
    response = repo.patch(url, json=data)

    if response.status_code != 200:
        raise RuntimeError(
            'Edit comment failed. Code: {}. Content: {!r}.'.format(
                response.status_code, response.content
            )
        )
示例#2
0
def edit_comment(repo: GithubRepository, text: str, comment_id: int) -> None:
    """
    References:
        https://developer.github.com/v3/issues/comments/#edit-a-comment
    """
    url = "https://api.github.com/repos/{}/{}/issues/comments/{}".format(
        repo.organization, repo.name, comment_id)
    data = {'body': text}
    response = repo.patch(url, json=data)

    if response.status_code != 200:
        raise RuntimeError(
            'Edit comment failed. Code: {}. Content: {!r}.'.format(
                response.status_code, response.content))