def pre_commit_hooks() -> None: """ Sets up git hooks """ try: get_git_dir() pre_commit(['install']) except CalledProcessError: log.warning( 'Git folder has not bee found! Proceed without git hooks setup step' )
def _hook_paths( hook_type: str, git_dir: Optional[str] = None, ) -> Tuple[str, str]: git_dir = git_dir if git_dir is not None else git.get_git_dir() pth = os.path.join(git_dir, 'hooks', hook_type) return pth, f'{pth}.legacy'
def test_get_git_dir(tmpdir): """Regression test for #1972""" src = tmpdir.join('src').ensure_dir() cmd_output('git', 'init', str(src)) git_commit(cwd=str(src)) worktree = tmpdir.join('worktree').ensure_dir() cmd_output('git', 'worktree', 'add', '../worktree', cwd=src) with worktree.as_cwd(): assert git.get_git_dir() == src.ensure_dir('.git/worktrees/worktree', ) assert git.get_git_common_dir() == src.ensure_dir('.git')
def _hook_paths(hook_type): pth = os.path.join(git.get_git_dir(), 'hooks', hook_type) return pth, '{}.legacy'.format(pth)
def git_dir(self): return git.get_git_dir(self.git_root)
def git_dir(self): return git.get_git_dir(self.git_root)
def _hook_paths(hook_type): pth = os.path.join(git.get_git_dir(), 'hooks', hook_type) return pth, '{}.legacy'.format(pth)
def _hook_paths(hook_type, git_dir=None): git_dir = git_dir if git_dir is not None else git.get_git_dir() pth = os.path.join(git_dir, 'hooks', hook_type) return pth, '{}.legacy'.format(pth)
def get_hook_path(self, hook_type): return os.path.join(git.get_git_dir(self.git_root), 'hooks', hook_type)