0

我正在尝试列出 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

到目前为止,我只能输出 repo 分支和名称。有任何想法吗?

4

1 回答 1

0

所以这就是我在挣扎了一段时间后解决它的方法:

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
于 2017-03-31T12:47:15.260 回答