0

我正在为项目编写更新脚本,其中远程代码应根据提供的版本号更新某些文件。
为此,在 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
4

1 回答 1

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)
于 2016-08-02T15:02:58.670 回答