如何从Github存储库获取并列出所有文件
我试图列出Github存储库中的所有文件如何从Github存储库获取并列出所有文件,git,github3.py,Git,Github3.py,我试图列出Github存储库中的所有文件 def listFiles(self, filepath): git = githubHandler(GH_USERNAME, GH_PASSWORD) gh, repo, branch = git.connect_to_github() tree = branch.commit.commit.tree.recurse() print repo.blob print branch 到目前为止,我只
def listFiles(self, filepath):
git = githubHandler(GH_USERNAME, GH_PASSWORD)
gh, repo, branch = git.connect_to_github()
tree = branch.commit.commit.tree.recurse()
print repo.blob
print branch
到目前为止,我只能输出回购分支和名称。
有什么想法吗?经过一段时间的努力,我就是这样解决的:
def list_filenames(self, filepath):
git = githubHandler(GH_USERNAME, GH_PASSWORD)
gh, repo, branch = git.connect_to_github()
tree = branch.commit.commit.tree.recurse()
for filename in tree.tree:
print("[*] Found file {0}".format(filename.path))
print filename.path
return None
以什么形式?您可以在cmd行中尝试
git ls tree-r
。github3.py中必须有相应的函数。我正在查找..到目前为止,我只能列出repo分支和master。如果我们能为github3创建一个我喜欢的函数,那就太酷了。