def git_file_statuses(): Logger.debug('[dvc-git] Getting file statuses. Command: git status --porcelain') code, out, err = Executor.exec_cmd(['git', 'status', '--porcelain']) if code != 0: raise ExecutorError('[dvc-git] File status command error - {}'.format(err)) Logger.debug('[dvc-git] Getting file statuses. Success.') return GitWrapper.parse_porcelain_files(out)
def curr_commit(self): Logger.debug('[dvc-git] Getting current git commit. Command: git rev-parse --short HEAD') code, out, err = Executor.exec_cmd(['git', 'rev-parse', 'HEAD']) if code != 0: raise ExecutorError('[dvc-git] Commit command error - {}'.format(err)) Logger.debug('[dvc-git] Getting current git commit. Success.') return out
def git_dir(self): if self._git_dir: return self._git_dir try: Logger.debug('[dvc-git] Getting git directory. Command: git rev-parse --show-toplevel') code, out, err = Executor.exec_cmd(['git', 'rev-parse', '--show-toplevel']) if code != 0: raise ExecutorError('[dvc-git] Git directory command error - {}'.format(err)) Logger.debug('[dvc-git] Getting git directory. Success.') self._git_dir = out return self._git_dir except ExecutorError: raise except Exception as e: raise ExecutorError('Unable to run git command: {}'.format(e)) pass
def curr_commit(self, branches=False): Logger.debug('[dvc-git] Getting current git commit. Command: git rev-parse --short HEAD') if branches: cmd = 'git rev-parse --abbrev-ref HEAD' else: cmd = 'git rev-parse HEAD' code, out, err = Executor.exec_cmd(cmd.split()) if code != 0: raise ExecutorError('[dvc-git] Commit command error - {}'.format(err)) Logger.debug('[dvc-git] Getting current git commit. Success.') return out