ubuntu svn post commit hook does not work, but wor

2019-08-28 00:59发布

问题:

/usr/bin/svn update /var/project2_test/debug --username XXXX--password XXXX
/bin/echo $REV >> /var/project2_test/svn.log

the log has been updated while committing. but working copy never update. And I run /home/admin/svn/project/hooks/post-commit by hand. IT WORKS!

回答1:

  1. Post-commit hook (any hook really)
    • running in empty environment
    • running under another user credentials, than on running by hand (user of SVN-server used)
  2. Anyway, you have to debug hook's script under real conditions (as hook). In orderto do it, you have
    • Intercept output of update command (by redirecting stdout to stderr)
    • Show this output to user, which perform commit, i.e, because stderr marshalled to user only in case of error in hook, you have to exit hook with non-zero exit-code

Hook in debug-stage will be something like

/usr/bin/svn update /var/project2_test/debug --username XXXX --password XXXX > &2
/bin/echo $REV >> /var/project2_test/svn.log
exit 1