No commit history issue

This commit is contained in:
Dmitry
2017-11-13 01:51:48 -08:00
parent 524901d4ad
commit b4bf6ffbd7
+8 -1
View File
@@ -427,13 +427,20 @@ class GitWrapper(GitWrapperI):
@staticmethod
def git_prev_commit():
cmd = 'git check-ref-format --branch @{-1}'
return Executor.exec_cmd_only_success(cmd.split()).strip()
code, out, err = Executor.exec_cmd(cmd.split())
if code != 0:
return ''
return out
@staticmethod
def state_files_for_previous_commit():
commit = GitWrapper.git_prev_commit()
Logger.debug(u'[dvc-git] Previous commit "{}"'.format(commit))
if not commit:
Logger.debug(u'[dvc-git] Previous commit does not exist')
return []
git_cmd = u'git ls-tree --name-only -r {}'.format(commit)
lines = Executor.exec_cmd_only_success(git_cmd.split()).split('\n')
return filter(lambda s: s.startswith(ConfigI.STATE_DIR), lines)