我正在为项目编写更新脚本,其中远程代码应根据提供的版本号更新某些文件 为此,标签(发布)在github中创建 现在我想下载这些文件,因为它们提交的是一个标记版本的标记。
>>> repo = github3.repository('Piletilevi', 'printsrv')
>>> for tag in repo.tags():
print(tag)
0.2.0
>>> for tag in repo.refs():
print(tag)
<Reference [refs/heads/master]>
<Reference [refs/heads/support-0.1]>
<Reference [refs/heads/1.0.0]>
<Reference [refs/tags/0.2.0]>
>>> for tag in repo.tags():
print(tag.as_dict()['commit']['sha'])
3322aa270ac921cd0d90cb7f543e8dd917fa3637
答案 0 :(得分:1)
我离解决方案只有几步:
>>> for tag in repo.tags():
if(tag.as_dict()['name'] == '0.2.0'):
sha = tag.as_dict()['commit']['sha']
print(repo.file_contents('package.json', sha).decoded)