Bonefisher
Bonefisher

Reputation: 509

How to get the name of branch in a post-commit hook in 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).

Upvotes: 6

Views: 6031

Answers (1)

Christopher Creutzig
Christopher Creutzig

Reputation: 8774

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

Upvotes: 9

Related Questions