The code below is equivalent to git command, "git ls-tree -r master --name-only".
import git
def get_tracked_files(trees):
paths = []
for tree in trees:
for blob in tree.blobs:
paths.append(blob.abspath)
if tree.trees:
paths.extend(get_tracked_files(tree.trees))
return paths
if __name__=='__main__':
repo = git.Repo('.')
tracked_files = get_tracked_files([repo.tree()])
print tracked_files
def get_tracked_files(trees):
paths = []
for tree in trees:
for blob in tree.blobs:
paths.append(blob.abspath)
if tree.trees:
paths.extend(get_tracked_files(tree.trees))
return paths
if __name__=='__main__':
repo = git.Repo('.')
tracked_files = get_tracked_files([repo.tree()])
print tracked_files
0 件のコメント:
コメントを投稿