def test_git_hooks_dir(self, git): hooks_dir = os.path.join(u"föo", ".git", "hooks") git.return_value.__str__ = lambda _: hooks_dir + "\n" git.return_value.__unicode__ = lambda _: hooks_dir + "\n" self.assertEqual(git_hooks_dir(u"/blä"), os.path.join(u"/blä", hooks_dir)) git.assert_called_once_with("rev-parse", "--git-path", "hooks", _cwd=u"/blä")
def test_git_hooks_dir(self, git): hooks_dir = os.path.join("föo", ".git", "hooks") git.return_value = hooks_dir + "\n" self.assertEqual(git_hooks_dir("/blä"), os.path.abspath(os.path.join("/blä", hooks_dir))) git.assert_called_once_with("rev-parse", "--git-path", "hooks", _cwd="/blä")
def _assert_git_repo(target): """ Asserts that a given target directory is a git repository """ hooks_dir = git_hooks_dir(target) if not os.path.isdir(hooks_dir): raise GitHookInstallerError(f"{target} is not a git repository.")
def commit_msg_hook_path(lint_config): return os.path.join(git_hooks_dir(lint_config.target), COMMIT_MSG_HOOK_DST_PATH)