通过github API,我列出了某个提交的所有文件和文件夹,如下所示:
https://api.github.com/repos/:owner/:repo/git/trees/:sha?recursive=1这给了我一个类似这样的列表:
{
"sha": "9fb037999f264ba9a7fc6274d15fa3ae2ab98312",
"url": "https://api.github.com/repos/octocat/Hello-World/trees/9fb037999f264ba9a7fc6274d15fa3ae2ab98312",
"tree": [
{
"path": "file.rb",
"mode": "100644",
"type": "blob",
"size": 30,
"sha": "44b4fc6d56897b048c772eb4087f854f46256132",
"url": "https://api.github.com/repos/octocat/Hello-World/git/blobs/44b4fc6d56897b048c772eb4087f854f46256132"
},
{
"path": "subdir",
"mode": "040000",
"type": "tree",
"sha": "f484d249c660418515fb01c2b9662073663c242e",
"url": "https://api.github.com/repos/octocat/Hello-World/git/blobs/f484d249c660418515fb01c2b9662073663c242e"
},
{
"path": "exec_file",
"mode": "100755",
"type": "blob",
"size": 75,
"sha": "45b983be36b73c0788dc9cbcb76cbb80fc7bb057",
"url": "https://api.github.com/repos/octocat/Hello-World/git/blobs/45b983be36b73c0788dc9cbcb76cbb80fc7bb057"
}
]
}但是我怎么知道文件发生了什么呢?比如,我怎么知道它是否在这个提交中被编辑了,或者重命名或者删除了等等?我似乎想不出怎么弄到这些信息。
我怎样才能得到这些信息呢?
发布于 2013-05-18 08:08:41
编辑、重命名或删除都是基于git日志中的历史记录。
因此,仅有tree API还不足以让GitHub提供该信息:您需要从与给定树或文件相关联的日志中提取该信息。
您可以使用API for commits来列出给定文件的提交,甚至将两个提交比较在一起,这将为您提供编辑方面的详细信息。
"files": [
{
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"filename": "file1.txt",
"status": "added",
"additions": 103,
"deletions": 21,
"changes": 124,
"blob_url": "https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
"raw_url": "https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
"patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"
}
]但我不认为你可以很容易地看到重命名仅仅通过API。
您必须将存储库克隆到git log -M --summary,才能看到这些移动/重命名。
https://stackoverflow.com/questions/16618033
复制相似问题