SVN hooks not working -
i have server repository of branch , trunk. branch team members' repositories. i'm trying utilize svn hooks
in repo under branch, doesn't seem work fine. in next steps tried approach:
checked out my_repo
remote server's branch/my_repo
since local repo my_repo
doesn't have content, created new svn repo locally , copied on including /hooks
folder my_repo
.
i created empty file in my_repo
, added line of text. svn add
file.
modified my_repo/hooks/pre-commit.tmpl
file , create not pass error code 1. looks like:
copy pre-commit.tmpl
pre-commit , add together execute permit of pre-commit myself
the server contains other people's server's construction like:
- server - branch - my_repo - myfile - hooks - pre-commit - tom's repo - other team member's repo - trunk in checked out repo committed changes using:svn commit -m "dumb change"
now here should not able commit , should give me error code 1 right? don't see anywhere.
then tried putting hooks folder @ top level , @ same level branch , trunk. i.e. construction looks like: -server - branches - my_repo - myfile - tom's repo - other team member's repo - trunk - hooks - pre-commitbut, still not working. sigh...
however, david's help, figured out , wrong: 1. highlight: ownership of hooks folder should same created repository. had inquire owner add together hooks files server. didn't create repository on server, files invisible in working directory. 2. here's tried:
1) on own linux system, `svnadmin create` new repository, maybe called test_server: in there folders: confs, db, hooks, locks; files: format, readme.txt 2) on same level, mkdir new folder (called working_dir) local working directory , checkout test_server. working_dir contains folder called test_server , it's empty. can't see of folders or files in step 1 3) modify test_server's hooks file described above. 4) seek add together file , add together new line file in working_dir/test_server folder , commit. 5) should see commit failed message: svn: commit blocked pre-commit hook(exit code 1) no output.thank much david , set comments earlier!
when run hook, stdout (what produced echo
statement) disabled. means script cannot utilize stdout print out anything, if has been redirected file.
instead, need open file descriptor instead of using 1
(stdout). can utilize exec
command open file descriptor, , pipe file:
exec 4> $my_file #opening my_file writing echo "this going $my_file" >&4
stderr redirected. output of stderr collected , sent calling client, when hook returns non-zero exit code. gives way communicate client why hook failed.
you must careful because environment hook runs in scrubbed. $path
null.
these of reasons why hook script run fine command line, not when executed hook.
if don't believe hook working, set exits non-zero exit code. if message subversion transaction failed, know hook script executed.
i recommend use, @ minimum, svnserve
deed subversion server -- if you're 1 using repository. never utilize file://
if i'm 1 using repository. svnserve
process pretty simple utilize , it's lightweight.
also, never utilize svn
in hook scripts. utilize svnlook
instead.
i want very, clear on this. need agree definitions:
the server machine running subversion repository. used commandsvnadmin create foo
create foo
directory deed repository itself. the repository directory directory on server created svnadmin create
command. server side of repository. not see files you've checked subversion here. instead, see hooks
directory , db
directory. server uses track changes. the working directory directory you've done svn checkout
checkout particular revision of project. the repository virtual view of repository directory when utilize various svn
commands svn ls
or svn log
or svn co
. not repository directory view of repository. okay, have settled:
hook scripts stored in repository directory under hooks
directory. when create repository directory, there sub-directory called hooks
templates hook scripts. these have *.tmpl
suffix. create hook, need replace 1 of these scripts hook script, , remove *.tmpl
suffix. hook script has have executable permission , owned user running subversion server process. (the user running httpd
or svnserve
command on server).
hooks entire repository. can't tell hook not fire when particular branch affected. however, hook script can see file located , take action based upon that. have pre-commit hook that. uses command file determine action needs take based upon location of file. however, every time commit happens, hook fire if doesn't have anything.
i hope answers questions.
svn hook commit
No comments:
Post a Comment