I am developing simple hook for git. It should cancel commit / push if Acrobat is opened on Windows Machine. Since Git hooks can not find windows process directly i am running next Powershell script named pre-commit.ps1
UPD No solution so far. Powershell exit 1 works fine with GitBash but ignored when called via TortoiseGit. It stated as fixes in Aug 2014 but does not look so for me
See https://gitlab.com/tortoisegit/tortoisegit/issues/2143
I am using TortoiseGit 1.8.15.2 from Sep 2015
$acrobat = Get-Process Acrobat -ErrorAction SilentlyContinue
if ($acrobat) {
"Acrobat is Running"
exit 1
} else {
"Not running"
exit 0
}
Remove-Variable acrobat
I placed file named pre-commit in .git\hooks folder of my project. It has next content
#!/bin/sh
# An hook script to verify that Acrobat is closed.
powershell.exe -ExecutionPolicy RemoteSigned -File '.\.\.\common\external\hooks\pre-commit.ps1'
ret=$?;
#echo "Acrobat check: $ret"
if [ $ret == 1 ]
then
echo "Commit canceled: Acrobat is open"
exit 1
fi
exit 0
The issues is: when i run pre-commit.ps1 directly it gives correct return 1 once Acrobat is open and 0 if not open. But in hook it always gives me 0.
Could you please give me a hint what is problem here? Or may be there is easier solution to return 1 in git hook without Powershell?