Skip to content

Instantly share code, notes, and snippets.

@TobiX
Created September 25, 2014 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TobiX/a2785a9af5a30ad23b00 to your computer and use it in GitHub Desktop.
Save TobiX/a2785a9af5a30ad23b00 to your computer and use it in GitHub Desktop.
SVN commit hook that denies changing of tags.
#!/bin/sh
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
# Make sure that the log message contains some text.
if ! $SVNLOOK log -t "$TXN" "$REPOS" | \
grep "[a-zA-Z0-9]" > /dev/null
then
echo "Bitte eine Commit-Meldung angeben!" >&2
exit 1
fi
# Deny transaction if any line writes to tags directory that exists.
CHANGED_TAG=`$SVNLOOK dirs-changed -t "$TXN" "$REPOS" 2>/dev/null | \
sed -n "/^tags\/./ { s|^tags/||; s|/.*$||; p; q; }"`
if [ "$CHANGED_TAG" ]
then
echo "Bereits existiterendes Tag ${CHANGED_TAG} kann nicht geaendert werden!" >&2
exit 1
fi
# 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