So I have trac installed with the trac-git plugin on Bitnami trac stack on windows. All is working fine however whenever I commit to my git repo I have to open use_trac.bat
and then call trac-admin ProjectName repository resync
before I can see the changes in trac.
Now what I want to do is call this line in the post-receive
hook of the repository but I'm struggling with how to call this from a bat file.
Anyone have any ideas how I can do this?
EDIT: So far I have this in my post-receive
echo "Resync repo"
"C:/path/to/repos/resync_git.bat"
Calling this bat file I wrote manually works but this isn't calling. I wonder if its because the hook isn't setup right for win?
Here's the contents of that file:
@echo off
CALL "C:\PROGRA~1\Trac\scripts\setenv.bat"
cd "C:\Program Files\Trac"
START "BitNami Trac Stack Environment" cmd
trac-admin C:/path/to/project changeset added "prjname"
I may use trac-admin C:/path/to/project repository resync "prjname"
here later...
This is what happens when that calls:
remote: Resync repo
remote: ./resync_git.bat: line 1: @echo: command not found
remote: ./resync_git.bat: line 2: CALL: command not found
remote: ./resync_git.bat: line 5: trac-admin: command not found
For one thing, the slashes in your pathname are backwards for a Windows system. That's probably not enough to derail the script, though.
When I've had issues with hook scripts failing but working when run manually, it's often come down to one of two things: what the script sees as the "current working directory" at the time it's executed, and the user account under which the script runs. You can solve the first problem by using absolute paths inside the script or by explicitly changing to a specific directory as the first line of the script. The second problem can be a bit trickier. Sometimes it's caused by permissions issues, and sometimes it's caused by the script running as a user that has a different PATH.
Either way, you need some more debugging information in order to figure out exactly what's going on here. In the command that launches the script, redirect stdout and stderr to log files so that you can capture any relevant output. Add the result into your question and I should be able to give you a more specific answer.
Another possibility worth trying is to eliminate the extra .bat file and simply place the 'trac-admin' call directly into the hook script.
Are you certain that your post-commit hook is running at all? Try adding a command like "echo [%TIME%] Hook script running >>C:\test.txt" to the top of the hook script and verify that something actually gets logged. If not, then git might not be seeing your hook script at all.