gpt4 book ai didi

GitHub Api : How to get Root :tree_sha of a repository?

转载 作者:行者123 更新时间:2023-12-04 17:58:55 25 4
gpt4 key购买 nike

如何通过GitHub API获取GitHub存储库的Root:tree_sha?

GitHib API帮助页面似乎无法解释以下关键信息:

http://develop.github.com/p/object.html

Can get the contents of a tree by tree SHA

tree/show/:user/:repo/:tree_sha

To get a listing of the root tree for the facebox project from our commit listing, we can call this:

$ curl http://github.com/api/v2/yaml/tree/show/defunkt/facebox/a47803c9ba26213ff194f042ab686a7749b17476

最佳答案

每个提交都包含该提交时整个树的阴影。
使用API​​获取代表master分支的JSON对象。

https://api.github.com/repos/:owner/:repo/branches/master

该分支的最后一次提交包括我认为您要求的树形阴影。

此段代码演示了如何在Python中获取 head_tree_sha
import requests
token = '0...f'
key = {'Authorization':'token '+token}
master = requests.get('https://api.github.com/repos/'+owner+'/' + repo '/branches/master', headers=key)
master = master.json()
head_tree_sha = master['commit']['commit']['tree']['sha']

https://developer.github.com/v3/git/commits/

关于GitHub Api : How to get Root :tree_sha of a repository?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2831137/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com