Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the name of branch in a post-commit hook in SVN?

Tags:

svn

There are two arguments put in post-commit hook in SVN by default: path to repo and revision number. I need to get to the branch folder (or trunk) in order to run build process only if a specific branch was commited (UAT branch).

like image 932
Bonefisher Avatar asked Jan 27 '11 12:01

Bonefisher


People also ask

What is post commit hook in SVN?

The post-commit hook is run after the transaction is committed and a new revision is created. Most people use this hook to send out descriptive emails about the commit or to notify some other tool (such as an issue tracker) that a commit has happened. Some configurations also use this hook to trigger backup processes.

Where are SVN hooks stored?

Where are SVN hooks stored?. Subversion Hooks are located in your repository directory (so if you have multiple repositories you have to setup hooks for each one) in a directory called hooks , perhaps something like this: /home/svn/projectName/hooks .

What is pre commit hook in SVN?

A pre-commit hook is a feature available in the Subversion version control system that allows code to be validated before it is committed to the repository. The PHP_CodeSniffer pre-commit hook allows you to check code for coding standard errors and stop the commit process if errors are found.


1 Answers

Subversion does not treat these folders special in any way. Regarding them as branches is just a convention you happen to follow.

Since a commit can, without any problems, go to multiple of the folders at the same time, you will have to use something like svnlook dirs-changed -r "$REV" "$REPOS" and check if one or more of the folders you are interested in is affected by the commit. Here's a snippet from our post-commit file:

if svnlook dirs-changed -r "$REV" "$REPOS" | grep -qEe '^trunk/'; then
  some-command.pl "$REPOS" "$REV" more parameters
fi
like image 108
Christopher Creutzig Avatar answered Sep 28 '22 15:09

Christopher Creutzig