def hackish_pull_list_changed_files(git_path):
"""Pull new updates from remote origin (hack, using git binary -
faster but not as safe as GitPython)."""
git_repo = git.Repo(git_path)
logging.info(" HEAD: " + str(git_repo.head.commit))
logging.info(" is detached: " + str(git_repo.head.is_detached))
logging.info(" is dirty: " + str(git_repo.is_dirty()))
if git_repo.head.is_detached:
raise Exception("Detached head")
if git_repo.is_dirty():
raise Exception("Dirty repository")
del git_repo
gc.collect()
files = set()
git_obj = git.Git(git_path)
pull_lines = git_obj.pull().splitlines()
del git_obj
gc.collect()
for line in pull_lines:
match = re.search(r'^ (.+) \| .*$', line)
if not match is None:
changed_files = match.group(1).split('=>')
for changed_file in changed_files:
files.add(changed_file.strip())
return list(files)
评论列表
文章目录