views:

86

answers:

3

Problem: apparently the scripts in the .git/hooks directory depend on the filename matching one of:

post-commit
pre-commit
pre-rebase

etc ...

No concept of "file extension" is required because the "shebang line" indicates how the file should run, as long as it is executable and running on your Linux box.

The problem is when you have some scripts that you want to run on a Windows box.

Question: Is there a way to execute the hook scripts that can be understood on a Windows machine?

+1  A: 

I don't think Windows has the concept of executing extension-less files. Workarounds would be to 1) use Cygwin git under bash, where the whole shebang business works or 2) a hack in the Windows git version that actually parses the shebang lines itself and loads the appropriate interpreter. I can see all sorts of philosophical objections to the latter, so I would guess that's not going to happen...

calmh
A: 

I actually settled for option 3):

Create a Windows "wrapper" script that invokes git and invokes any associated hooks that I want to run. The downside is I have to configure the wrapper program to do what git would have done automatically if only I could just use the standard hook files.

dreftymac
+1  A: 

I know I'm way behind on this, but I have a solution for you. If you're using python, add ".py" to the PATHEXT environment variable (Control Panel, System, Advanced, Environment Variables). Likewise for your specific scripting language. Then name the hooks post-commit.py, pre-commit.py, etc. When a program asks Windows to execute the "post-commit" file in a certain directory, Windows will look through PATHEXT in order until it finds a file matching "post-commit.extension", which it will then execute. I did this a long time ago with svn hooks on Windows.

robert