1

I have one repository and one working copy of it.

In the post-commit hook of repository I have written a command to execute one file which run the command of SVN update.

My repository is in the /var/www/svnrepos/help/

My working copy is in /var/www/autopostcommit/help/

Post-commit file is in the /var/www/svnrepos/help/hooks/

In the post-commit I have written following command

    sudo /usr/local/bin/svn-post-commit-update 1>&2

In the svn-post-commit-update file which is in /usr/local/bin I have written following command.

    cd /var/www/autopostcommit/help/
    svn update --non-interactive --trust-server-cert \
               --username satish@108.166.92.199 --password mypassword

I have also tried other version of command for the update like without password and all.

SVN commit gives me following error

   Error: sudo: no tty present and no askpass program specified

How can I get past this error?

Rob Kielty
  • 7,958
  • 8
  • 39
  • 51
Satish
  • 1,012
  • 2
  • 15
  • 32

3 Answers3

1

You have configured sudo to ask for a password, which it cannot do in a the post-commit hook. Fix seems simple: Reconfigure sudo so it will not ask for a password in your case.

Cautious people don't want to run the post-commit hook as root anyway.

Turbo J
  • 7,563
  • 1
  • 23
  • 43
0

You'll need to find some other way to execute your script as the correct user. Maybe making the script setuid is an option for you? http://en.wikipedia.org/wiki/Setuid

Then you can remove the sudo.

Colin 't Hart
  • 7,372
  • 3
  • 28
  • 51
0

The real question: What are you trying to do?

When you execute a post-commit hook, the user who is doing the commit has to wait around until it's finished. If you're trying to update a remote working directory, your user is going to get very upset because each time they do a commit, it's going to take 10 to 20 seconds of thumb twiddling before hey get their computer back.

Some things are better not to do as a hook. Instead, use a crontab entry that simply checks the repository every minute for an update, and if there is an update, does whatever it needs to do.

I take it you're updating a webpage. My I make a slight suggestion: Don't use svn update. Instead use svn export which will get rid of all the .svn files (which I guess with version 1.7 isn't all that bad anymore). What I recommend doing is a two directory strategy:

You don't update your /var/www/autopostcommit/help/ directly. Instead you do a svn update to another directory, then after the update is complete, move the /var/www/autopostcommit/help elsewhere, and move the directory you've exported to /var/www/autopostcommit/help/. This way, your /var/www/autopostcommit/help directory isn't in a state that's halfway between two revisions.

David W.
  • 105,218
  • 39
  • 216
  • 337