GitHub/GitLab REST API - 获取两个分支之间的差异
GitHub/GitLab REST API - Get diff between two branches
我们想通过 REST API 获得两个 GitLab/GitHub 分支之间的差异。我们看到 Git 支持执行此操作的命令,但他们似乎不支持 REST API。是否有任何 API 对此的支持?
git diff --name-status firstbranch..yourBranchName
git diff --name-status origin/develop..origin/master
Showing which files have changed between two revisions
GitHub 已将 URL(非 REST)用于 comparing branches。
示例:
https://github.com/octocat/linguist/compare/master...octocat:an-example-comparison-for-docs
GitLab 相同:
https://gitlab.com/gitlab-org/gitlab-foss/compare?from=master&to=master
虽然可以different from a git diff.
GitHub 的 REST API 将是:“Compare two commits”
GET /repos/:owner/:repo/compare/:base...:head
The response also includes details on the files that were changed between the two commits.
This includes the status of the change (for example, if a file was added, removed, modified, or renamed), and details of the change itself.
For example, files with a renamed status have a previous_filename
field showing the previous filename of the file, and files with a modified
status have a patch field showing the changes made to the file.
对于 GitLab:compare branch API
GET /projects/:id/repository/compare?from=master&to=feature
我们想通过 REST API 获得两个 GitLab/GitHub 分支之间的差异。我们看到 Git 支持执行此操作的命令,但他们似乎不支持 REST API。是否有任何 API 对此的支持?
git diff --name-status firstbranch..yourBranchName
git diff --name-status origin/develop..origin/master
Showing which files have changed between two revisions
GitHub 已将 URL(非 REST)用于 comparing branches。
示例:
https://github.com/octocat/linguist/compare/master...octocat:an-example-comparison-for-docs
GitLab 相同:
https://gitlab.com/gitlab-org/gitlab-foss/compare?from=master&to=master
虽然可以different from a git diff.
GitHub 的 REST API 将是:“Compare two commits”
GET /repos/:owner/:repo/compare/:base...:head
The response also includes details on the files that were changed between the two commits.
This includes the status of the change (for example, if a file was added, removed, modified, or renamed), and details of the change itself.
For example, files with a renamed status have aprevious_filename
field showing the previous filename of the file, and files with amodified
status have a patch field showing the changes made to the file.
对于 GitLab:compare branch API
GET /projects/:id/repository/compare?from=master&to=feature