Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a hack for fully functional cross-platform shebang line?

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?

like image 209
dreftymac Avatar asked Oct 23 '25 22:10

dreftymac


1 Answers

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.

like image 137
robert Avatar answered Oct 26 '25 23:10

robert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!