[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Example post commit hook denying access to existing /tags/ items (or their children)

From: Erik Huelsmann <e.huelsmann_at_gmx.net>
Date: 2003-11-14 19:02:54 CET

Because there have been many complaints that Subversion allows changes to
its tags/ directories, I wrote the pre-commit hook below as an example how to
deny such commits, while keeping the possibility to add new items.

I thought to submit the script here for comments. In the end it might find
it's destination in the /contrib/ directory, or as part of the example
pre-commit hook. More flexible versions could be coded, preferrably in python, but
admins could do that themselves too.

So: let's have the comments please.

bye,

Erik.

#!/bin/sh

# for repo structure
# /trunk
# /branches
# /tags
#
# use the regex below:
TAGS_REGEX='tags/[^/]\+'

# for repo structure
# /project1
# /trunk
# /branches
# /tags
# /project2
# .. etc ..
#
# use the regex below:
#TAGS_REGEX='[^/]\+/tags/[^/]\+'

REPOS="$1"
TXN="$2"

TARGETS=` \
     svnlook changed -t "$TXN" "$REPOS" 2>/dev/null | \
     awk '{ print $2; }' 2>/dev/null | \
     grep ^tags/ 2>/dev/null `
YOUNGEST=`svnlook youngest "$REPOS" 2>/dev/null`

for target in $TARGETS; do
  tag=`echo $target | sed -e "s!^\($TAGS_REGEX\).*!\1!" | sort | uniq`
  # statement below errors if tag does not exist...
  if svnlook pl -r $YOUNGEST "$REPOS" "$tag" >/dev/null 2>&1 ; then
    echo "Cannot commit to or into existing tag '$tag'" >&2
    exit 1
  fi
done

exit 0

-- 
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService
Jetzt kostenlos anmelden unter http://www.gmx.net
+++ GMX - die erste Adresse für Mail, Message, More! +++
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Nov 14 19:04:03 2003

This is an archived mail posted to the Subversion Dev mailing list.