我正在编写使用 gitlab api 的应用程序。
为此,我想通过分支和提交消息搜索/过滤提交。
但是 Gitlab 支持两个端点,它们是
搜索 :
/api/v4/projects/24/search?scope=commits&search=fixed
这将仅按消息过滤,而不是按分支过滤。
从提交 api
/projects/:id/repository/commits
即使这种支持也只支持少数参数。
但我想过滤为特定分支完成的提交。
我正在编写使用 gitlab api 的应用程序。
为此,我想通过分支和提交消息搜索/过滤提交。
但是 Gitlab 支持两个端点,它们是
搜索 :
/api/v4/projects/24/search?scope=commits&search=fixed
这将仅按消息过滤,而不是按分支过滤。
从提交 api
/projects/:id/repository/commits
即使这种支持也只支持少数参数。
但我想过滤为特定分支完成的提交。
不要认为您可以在单个 api 调用中通过消息和分支获得过滤响应。
GET /projects/:id/repository/commits?ref_name=<your branch name>
示例响应:
[
{
"id": "ed899a2f4b50b4370feeea94676502b42383c746",
"short_id": "ed899a2f4b5",
"title": "Replace sanitize with escape once",
"author_name": "Example User",
"author_email": "user@example.com",
"authored_date": "2012-09-20T11:50:22+03:00",
"committer_name": "Administrator",
"committer_email": "admin@example.com",
"committed_date": "2012-09-20T11:50:22+03:00",
"created_at": "2012-09-20T11:50:22+03:00",
"message": "Replace sanitize with escape once", ----> Message
"parent_ids": [
"6104942438c14ec7bd21c6cd5bd995272b3faff6"
],
"web_url": "https://gitlab.example.com/thedude/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746"
}
]
GET /projects/:id/repository/commits/:sha/refs
但这将需要两个 API 调用,一个是获取按消息过滤的提交,然后是获取提交所属的引用列表。[
{"type": "branch", "name": "'test'"},
{"type": "branch", "name": "add-balsamiq-file"},
{"type": "branch", "name": "wip"},
{"type": "tag", "name": "v1.1.0"}
]