有没有办法使用命令获取拉取请求描述?

问题描述 投票:0回答:2

我有 PR,我必须获取 PR 的描述。

我知道有一种方法可以使用 API 来获取此信息。但是有没有 git 命令可以使用它来获取分支的 PR 详细信息?

github github-actions github-api
2个回答
1
投票

你可以使用 github cli

然后:

gh pr status


0
投票

没有 git 命令可以满足您的要求。但使用 GitHub CLI(按照 Ôrel 的建议)就可以了。

高公关视图

❯ gh pr view
Release v1.1.0 haraka/haraka-notes#21
Draft • msimerson wants to merge 2 commits into master from release-1.1.0 • about 7 minutes ago
+134 -113 • × 1/13 checks failing

                                                                                                                      
  • set: add 'default' mode.                                                                                          


View this pull request on GitHub: https://github.com/haraka/haraka-notes/pull/21

通过 gh 的 GH API

gh
CLI 还可以与 jq 很好地配合,通过 API 获取数据位,例如这个获取 PR 的描述正文的示例。

❯ gh api \
   -H 'Accept: application/vnd.github+json' \
   -H 'X-GitHub-Api-Version: 2022-11-28' \
   /repos/haraka/haraka-notes/pulls/21 \
   | jq '.body'
"- set: add 'default' mode."
© www.soinside.com 2019 - 2024. All rights reserved.