@@ -1068,28 +1068,28 @@ def test_run_commit_hook(self, rw_repo):
10681068 @with_rw_repo ("HEAD" , bare = False )
10691069 def test_run_commit_hook_respects_core_hookspath (self , rw_repo ):
10701070 """Test that run_commit_hook() respects core.hooksPath configuration.
1071-
1071+
10721072 This addresses issue #2083 where commit hooks were always looked for in
10731073 $GIT_DIR/hooks instead of respecting the core.hooksPath config setting.
10741074 """
10751075 index = rw_repo .index
1076-
1076+
10771077 # Create a custom hooks directory outside of .git
10781078 custom_hooks_dir = Path (rw_repo .working_tree_dir ) / "custom-hooks"
10791079 custom_hooks_dir .mkdir ()
1080-
1080+
10811081 # Create a hook in the custom location
10821082 custom_hook = custom_hooks_dir / "fake-hook"
10831083 custom_hook .write_text (HOOKS_SHEBANG + "echo 'ran from custom hooks path' >output.txt" )
10841084 custom_hook .chmod (0o744 )
1085-
1085+
10861086 # Set core.hooksPath in the repo config
10871087 with rw_repo .config_writer () as config :
10881088 config .set_value ("core" , "hooksPath" , str (custom_hooks_dir ))
1089-
1089+
10901090 # Run the hook - it should use the custom path
10911091 run_commit_hook ("fake-hook" , index )
1092-
1092+
10931093 output_file = Path (rw_repo .working_tree_dir ) / "output.txt"
10941094 self .assertTrue (output_file .exists (), "Hook should have created output.txt" )
10951095 output = output_file .read_text (encoding = "utf-8" )
@@ -1108,28 +1108,28 @@ def test_run_commit_hook_respects_core_hookspath(self, rw_repo):
11081108 @with_rw_repo ("HEAD" , bare = False )
11091109 def test_run_commit_hook_respects_relative_core_hookspath (self , rw_repo ):
11101110 """Test that run_commit_hook() handles relative core.hooksPath correctly.
1111-
1111+
11121112 Per git-config docs, relative paths for core.hooksPath are relative to
11131113 the directory where hooks are run (typically the working tree root).
11141114 """
11151115 index = rw_repo .index
1116-
1116+
11171117 # Create a custom hooks directory with a relative path
11181118 custom_hooks_dir = Path (rw_repo .working_tree_dir ) / "relative-hooks"
11191119 custom_hooks_dir .mkdir ()
1120-
1120+
11211121 # Create a hook in the custom location
11221122 custom_hook = custom_hooks_dir / "fake-hook"
11231123 custom_hook .write_text (HOOKS_SHEBANG + "echo 'ran from relative hooks path' >output.txt" )
11241124 custom_hook .chmod (0o744 )
1125-
1125+
11261126 # Set core.hooksPath to a relative path
11271127 with rw_repo .config_writer () as config :
11281128 config .set_value ("core" , "hooksPath" , "relative-hooks" )
1129-
1129+
11301130 # Run the hook - it should resolve the relative path correctly
11311131 run_commit_hook ("fake-hook" , index )
1132-
1132+
11331133 output_file = Path (rw_repo .working_tree_dir ) / "output.txt"
11341134 self .assertTrue (output_file .exists (), "Hook should have created output.txt" )
11351135 output = output_file .read_text (encoding = "utf-8" )
@@ -1158,19 +1158,19 @@ def test_run_commit_hook_respects_core_hookspath_bare_repo(self, rw_repo):
11581158 # Use a unique name based on the repo to avoid conflicts
11591159 custom_hooks_dir = Path (rw_repo .git_dir ).parent / "bare-custom-hooks"
11601160 custom_hooks_dir .mkdir (exist_ok = True )
1161-
1161+
11621162 # Create a hook in the custom location
11631163 custom_hook = custom_hooks_dir / "fake-hook"
11641164 custom_hook .write_text (HOOKS_SHEBANG + "echo 'ran from custom hooks path in bare repo' >output.txt" )
11651165 custom_hook .chmod (0o744 )
1166-
1166+
11671167 # Set core.hooksPath in the repo config (absolute path)
11681168 with rw_repo .config_writer () as config :
11691169 config .set_value ("core" , "hooksPath" , str (custom_hooks_dir ))
1170-
1170+
11711171 # Run the hook - it should use the custom path
11721172 run_commit_hook ("fake-hook" , index )
1173-
1173+
11741174 # Output goes to cwd, which for bare repos during hook execution is git_dir
11751175 output_file = Path (rw_repo .git_dir ) / "output.txt"
11761176 self .assertTrue (output_file .exists (), "Hook should have created output.txt" )
0 commit comments