Create a gist now

Instantly share code, notes, and snippets.

Deny commits to tags in a subversion repository via pre-commit hook. http://svnbook.red-bean.com/en/1.7/svn.ref.reposhooks.pre-commit.html
#!/bin/sh
# Save in `hooks/pre-commit` and `chmod +x hooks/pre-commit`
# source: http://stackoverflow.com/a/576261
#
# Denies commits to tags with a pre-commit hook
REPOS="${1}"
TXN="${2}"
SVNLOOK='/usr/bin/svnlook'
# Committing to tags is not allowed
$SVNLOOK changed -t "${TXN}" "${REPOS}" | grep '^U\W*tags' && /bin/echo 'Cannot commit to tags!' 1>&2 && exit 1
# All checks passed, so allow the commit
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment