[英]How do I find commit hash of a file using GitLab API?
我試圖找出我的存儲庫中文件的提交哈希是什么。 不同的文件被不同的提交修改。
但是如何使用 GitLab API 獲取這些信息? 我試着做:
GET /projects/:id/repository/files
https://gitlab_server/api/v3/projects/1234/repository/files?file_path=test/file2.tconf&ref=master
但是響應中的 commit_id 匹配 HEAD 的哈希0f05a8e4bf45942b1189fce923184129821845f1 ,而不是上面截圖中看到的。
{
"file_name": "file2.tconf",
"file_path": "test/file2.tconf",
"size" : 44,
"encoding" : "base64",
"content" : "...",
"ref" : "master",
"blob_id" : "50450759d2b0694b044ed3d7eaf93c2c98dacbba",
"commit_id": "0f05a8e4bf45942b1189fce923184129821845f1"
}
有什么線索嗎?
last-commit-id現在存在並提供您所要求的內容:修改該特定文件的最后一次提交。
get-a-single-commit我剛剛為我的項目親自測試了它,用它來獲取有關上次提交的信息,我想您現在可以輕松獲得您想要的東西。
參見GitLab 的 get-a-single-commit
獲取 /projects/:id/repository/commits/:sha
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/commits/master"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.