Reputation: 91
I've a problem with my SVN post-commit hook. The hook itself works fine.
I've added:
echo "REPOS: $REPOS Rev: $REV" >>/tmp/mylog.txt
.. and when I'm running it by using the shell as www-data all works fine and the output is:
REPOS: /var/local/svn/svn_project Rev: 624
But when SVN called the hook automatically, the hook is executing and the output is:
REPOS: Rev:
The result is, that the update-command in my hook file also didn't work.. :/
Did someone have an idea where the problem could be? Why are the $REPOS and $REV not setted?
Upvotes: 1
Views: 1868
Reputation: 1324317
Why are the
$REPOS
and$REV
not setted?
Because you need to set those in your script. See this article:
The hooks are invoked with ordered arguments.
The first one in each case is$REPOS
(the path to the repository), and then the second argument is different in each case:
start-commit
: $USER
(the user attempting to commit)pre-commit
: $TXN-NAME
(the name of the transaction about to be committed. This is by default generated from the number of the current revision.)post-commit
: $REV
(the number of the revision just committed).Whilst these are the default arguments and the standard names for them, of course the script won’t know the argument names until you set them! They are passed in just as ordered arguments (so
$1
and$2
in bash, for example).
It’s good practice to set the appropriate named variables at the start of the script, and certainly before you call any other script, to avoid confusing yourself unnecessarily. So for example with a post-commit script in sh:
#!/bin/sh
REPOS="$1"
REV="$2"
SCRIPT="/home/username/svn/repository/hooks/script.pl"
"$SCRIPT" "$REPOS" "$REV" thirdarg || exit 1
Upvotes: 2