python - 如何在拉取请求上创建问题评论?

标签 python github-api github3.py

根据 this question PR 只是一个问题,上面有一些事情。

如何获取关联的问题ID?

我刚看到issue_url作为拉取请求对象的属性。 此外,PR 有方法 create_review_comment 但没有方法 create_issue_comment

这样的方法会是什么样子?

如何在 Pull Request 中创建问题评论?

最佳答案

我能够通过从 PR 编号中获取问题来做到这一点。事实上,在 github 中,每次创建拉取请求时都会创建一个“隐藏”问题。

所以下面的代码有效:

gh = ... # Connection
repo = gh.repository(user, repo_name)
pr = repo.create_pull(description, base, from_branch, detailed)
issue = repo.issue(pr.number)
issue.create_comment(comment)

也可以使用 other ways to get the issue from PR number .

不知道有没有比这更直接的方法

关于python - 如何在拉取请求上创建问题评论?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31381789/

相关文章:

python - 列出用户的 repo

python - Django - SQL 查询 - 时间戳

python - 在 Visual Studio Code 中将焦点切换到 Jupyter (IPython) 终端

javascript - 当通过 post 请求发送有效的 json 数据时,Flask request.get_json() 返回 None

github-api - 如何通过github api获取所有用户仓库? (包括固定存储库)

github 远程标签推送无需克隆 repo

github - 从 GitHub 存储库获取文件信息的 GraphQL 查询

python - github3.py。已提交文件的空列表

python - 获取所有 github 用户详细信息

python - 为什么我在构建 python 时构建 sqlite3 失败?