gitlab api 如何获取 Last Commit? logs_tree?

gitlab api How to get Last Commit? logs_tree?

gitlab api 如何获取 Last Commit?

GET /projects/:id/repository/tree

{
    "name": "assets",
    "type": "tree",
    "mode": "040000",
    "id": "6229c43a7e16fcc7e95f923f8ddadb8281d9c6c6"
  },?

如何获得logs_tree?上次提交?

我建议遵循列出的规范 here,其中说明您可以使用
GET /projects/:id/repository/commits/tree
return 以下示例数据:

{
  "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
  "short_id": "6104942438c",
  "title": "Sanitize for network graph",
  "author_name": "randx",
  "author_email": "dmitriy.zaporozhets@gmail.com",
  "created_at": "2012-09-20T09:06:12+03:00",
  "message": "Sanitize for network graph",
  "committed_date": "2012-09-20T09:06:12+03:00",
  "authored_date": "2012-09-20T09:06:12+03:00",
  "parent_ids": [
    "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
  ],
  "status": "running"
}

这是最新的提交。在查找 logs_tree 方面,full documentation 可能会对您有所帮助

在当前版本API我们只有一种方法可以解决这个问题

GET /api/v4/projects/:id/repository/commits

数组中的第一个提交将是所需的提交。您可以使用 jq '.[0]'

提取它

GitLab 至少从 12.10 版本开始支持分页。 这就是调用 return 只有一次提交的原因。

GET /api/v4/projects/:id/repository/commits?per_page=1&page=1