예제 #1
0
    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)
예제 #2
0
 def git_config_get(name):
     code, out, err = Executor.exec_cmd(['git', 'config', '--get', name])
     Logger.debug(
         '[dvc-git] "git config --get {}": code({}), out({}), err({})'.
         format(name, code, out, err))
     if code != 0:
         return None
     return out
예제 #3
0
    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
예제 #4
0
    def _get_symlink_string(path):
        code, output, _ = Executor.exec_cmd(["dir", path], shell=True)
        if code != 0:
            return None

        lines = output.split('\n')
        for line in lines:
            if System.SYMLINK_OUTPUT in line:
                return line
        return None
예제 #5
0
    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
예제 #6
0
    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
예제 #7
0
 def is_inside_work_tree(self):
     code, out, err = Executor.exec_cmd(['git', 'rev-parse', '--is-inside-work-tree'])
     if code != 0:
         Logger.error('[dvc-git] Not inside git tree');
     return code == 0
예제 #8
0
파일: git_wrapper.py 프로젝트: tanthml/dvc
 def git_prev_commit():
     cmd = 'git check-ref-format --branch @{-1}'
     code, out, err = Executor.exec_cmd(cmd.split())
     if code != 0:
         return ''
     return out
예제 #9
0
파일: git_wrapper.py 프로젝트: tanthml/dvc
 def checkout_previous():
     Logger.debug('[dvc-git] Checkout previous')
     cmd = 'git checkout -'
     return Executor.exec_cmd(cmd.split())
예제 #10
0
파일: git_wrapper.py 프로젝트: tanthml/dvc
 def checkout(commit_or_branch, create_new=False):
     prefix = '-b ' if create_new else ''
     Logger.debug('[dvc-git] Checkout {}{}'.format(prefix,
                                                   commit_or_branch))
     cmd = 'git checkout {}{}'.format(prefix, commit_or_branch)
     return Executor.exec_cmd(cmd.split())