@@ -1261,13 +1261,15 @@ def test_run_commit_hook_respects_absolute_hooks_path(self, rw_repo):
12611261 custom_hooks_dir = osp .join (rw_repo .working_dir , "custom-hooks" )
12621262 os .makedirs (custom_hooks_dir , exist_ok = True )
12631263 hp = osp .join (custom_hooks_dir , "fake-hook" )
1264+ # Use a Python script so it works on all platforms (no bash required)
1265+ hook_script = "#!" + sys .executable + "\n import sys; open('output.txt', 'w').write('ran custom hook\\ n')\n "
12641266 with open (hp , "w" , encoding = "utf-8" ) as f :
1265- f .write ("#!/bin/sh \n echo 'ran custom hook' >output.txt \n " )
1267+ f .write (hook_script )
12661268 os .chmod (hp , 0o755 )
12671269
12681270 rw_repo .config_writer ().set_value ("core" , "hooksPath" , custom_hooks_dir ).release ()
12691271 run_commit_hook ("fake-hook" , index )
1270- output = Path (rw_repo .git_dir , "output.txt" ).read_text (encoding = "utf-8" )
1272+ output = Path (rw_repo .working_dir , "output.txt" ).read_text (encoding = "utf-8" )
12711273 self .assertEqual (output , "ran custom hook\n " )
12721274
12731275 @pytest .mark .xfail (
@@ -1287,13 +1289,15 @@ def test_run_commit_hook_respects_relative_hooks_path(self, rw_repo):
12871289 custom_hooks_dir = osp .join (rw_repo .working_dir , "hooks-relative" )
12881290 os .makedirs (custom_hooks_dir , exist_ok = True )
12891291 hp = osp .join (custom_hooks_dir , "fake-hook" )
1292+ # Use a Python script so it works on all platforms (no bash required)
1293+ hook_script = "#!" + sys .executable + "\n import sys; open('output.txt', 'w').write('ran relative hook\\ n')\n "
12901294 with open (hp , "w" , encoding = "utf-8" ) as f :
1291- f .write ("#!/bin/sh \n echo 'ran relative hook' >output.txt \n " )
1295+ f .write (hook_script )
12921296 os .chmod (hp , 0o755 )
12931297
12941298 rw_repo .config_writer ().set_value ("core" , "hooksPath" , "hooks-relative" ).release ()
12951299 run_commit_hook ("fake-hook" , index )
1296- output = Path (rw_repo .git_dir , "output.txt" ).read_text (encoding = "utf-8" )
1300+ output = Path (rw_repo .working_dir , "output.txt" ).read_text (encoding = "utf-8" )
12971301 self .assertEqual (output , "ran relative hook\n " )
12981302
12991303 @with_rw_repo ("HEAD" , bare = True )
0 commit comments