Fix coverage and path to repo dir

This commit is contained in:
Simon Segerblom Rex 2024-03-14 13:59:50 +01:00
parent 7923236bb6
commit 42fe699ef4
2 changed files with 11 additions and 2 deletions

View file

@ -75,9 +75,10 @@ def _install_hook_script(
git_dir = git_dir if git_dir is not None else git.get_git_common_dir()
# If the hooks directory links to a directory outside the
# git repo we shouldn't try to mess with it
repo_dir = os.path.dirname(os.path.realpath(git_dir))
if os.path.commonpath(
[os.path.realpath(git_dir), os.path.realpath(hook_path)],
) != os.path.realpath(git_dir):
[repo_dir, os.path.realpath(hook_path)]
) != repo_dir:
logger.error(
'Cowardly refusing to install hook script to a directory '
'outside of the git repo.\n'