Question

I have an SVN repo set up on my server and am having post-commit issues. I am using SmartSVN as my client on my iMac. I connect through ssh+svn from SmartSVN. I am able to successfully connect to the SVN and make changes to it, but my post-commit script is not working after I commit from my SVN client.

I created my post-commit shell script named post-commit.sh and put it in the hooks directory thinking this was all you had to do in order to get it working. Basically what the script does is SVN checkout to a temporary workspace, then upload the necessary files to my development subdomain on my server. I do this so that I can have a testing environment for all changes that users make for my web application. The file originally looked liked this.

rm -rf /home/modionzc/tempworkspace/artistcondevspace/*
cd /home/modionzc/tempworkspace/artistcondevspace
svn checkout file:///home/modionzc/svnrepos/artistcondevrep
rm -rf /home/modionzc/public_html/devsuper/application/*
rm -rf /home/modionzc/public_html/devsuper/css/*
rm -rf /home/modionzc/public_html/devsuper/js/*
rm -rf /home/modionzc/public_html/devsuper/images/*
cp -r /home/modionzc/tempworkspace/artistcondevspace/artistcondevrep/trunk/application/* /home/modionzc/public_html/devsuper/application/
cp -r /home/modionzc/tempworkspace/artistcondevspace/artistcondevrep/trunk/css/* /home/modionzc/public_html/devsuper/css/
cp -r /home/modionzc/tempworkspace/artistcondevspace/artistcondevrep/trunk/js/* /home/modionzc/public_html/devsuper/js/
cp -r /home/modionzc/tempworkspace/artistcondevspace/artistcondevrep/trunk/images/* /home/modionzc/public_html/devsuper/images/
cp /home/modionzc/artistconconfig/appconfigfiles/config.php /home/modionzc/public_html/devsuper/application/config/config.php
cp /home/modionzc/artistconconfig/appconfigfiles/database.php /home/modionzc/public_html/devsuper/application/config/database.php
cd /home/modionzc/public_html/devsuper
chmod -R 755 *
chmod 644 $(find *.* ! -type d)

It runs perfectly normally when I run it manually from the command line and updates the necessary files. Now for some reason it is not being called whenever I commit from my SmartSVN. The changes are made through the repository and if I run the script manually I can see that the updates were actually made. I did some research and found out that it could be permission issues or that I'm not using absolute paths. I am using absolute paths throughout the script. The permissions to the file is set to 755. The only thing that I can think of is the actual SVN user doesn't have permission which are the users created in the conf file. I have looked through the SVN manual and over the internet for a fix without much success.

One suggestion was to to make a log file to see any errors that are caused when the script is called. So now my post-commit script calls another file that has the commands above and outputs the command line returns to a file called svna.log. The post-commit.sh file looks like this now.

cd /home/modionzc/hooktest/
/home/modionzc/hooktest/ac_post_commit.sh &> svna.log

Where ac_post_commit.sh has the original code above. Again if I call it manually all the responses go to the file as necessary, but if I commit my work from SmartSVN the log file is actually empty.

FYI - for some reason my post-commit.sh has a * at the end of it and is listed as post-commit.sh* when I ls the files in the hooks directory.

Please, any help with this would be greatly appreciated.

Was it helpful?

Solution

I found out that the issue on the svn forums while looking at another persons post here http://www.svnforum.org/threads/40951-How-repository-hooks-works?highlight=post-commit . The problem lies with the fact that the post-commit file cannot have a .sh appended to the end of it. It needs to be named just "post-commit". This does need to have the path to the type of script that you are writing in the first line which was mentioned by Mensi above but was not the problem with the script. Thanks for your help anyway.

OTHER TIPS

Could it be you are missing a #!/bin/sh at the beginning?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top