diff --git a/kart/lfs_util.py b/kart/lfs_util.py index bc23bfdf0..16da38813 100644 --- a/kart/lfs_util.py +++ b/kart/lfs_util.py @@ -27,6 +27,7 @@ def install_lfs_hooks(repo): pre_push_hook = repo.gitdir_path / "hooks" / "pre-push" if not pre_push_hook.is_file(): + pre_push_hook.parent.mkdir(parents=True, exist_ok=True) pre_push_hook.write_text(PRE_PUSH_HOOK) pre_push_hook.chmod( pre_push_hook.stat().st_mode | stat.S_IXOTH | stat.S_IXGRP | stat.S_IXUSR diff --git a/tests/point_cloud/test_hooks.py b/tests/point_cloud/test_hooks.py new file mode 100644 index 000000000..0dde5cf36 --- /dev/null +++ b/tests/point_cloud/test_hooks.py @@ -0,0 +1,15 @@ +from kart.repo import KartRepo +from kart.lfs_util import install_lfs_hooks + + +def test_install_lfs_hooks(tmp_path, cli_runner, chdir): + """Create an empty Kart repository.""" + repo_path = tmp_path / "repo" + repo_path.mkdir() + + # empty dir + r = cli_runner.invoke(["init", str(repo_path)]) + assert r.exit_code == 0, r + + repo = KartRepo(repo_path) + install_lfs_hooks(repo)