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

RE: pre-commit hook

From: Res Pons <pons32_at_hotmail.com>
Date: 2006-02-28 18:57:04 CET

All of your files must have execute permissions [and access to the sudo'ers
table especially if being served via a server]. See mine:

-rwxr-xr-x 1 www www 18949 Sep 27 13:23 commit-email.pl
-rwxr-xr-x 1 www www 2415 Jan 4 09:28 post-commit
-rwxr-xr-x 1 www www 2254 Oct 10 11:53 post-revprop-change
-rwxr-xr-x 1 www www 3994 Aug 4 2005 pre-commit
-rwxr-xr-x 1 www www 2615 Sep 15 09:50 pre-revprop
-rwxr-xr-x 1 www www 2763 Oct 13 14:01 pre-revprop-change
-rwxr-xr-x 1 www www 15839 Oct 10 12:11 propchange-email.pl
drwxr-xr-x 2 www www 4096 Oct 10 12:19 Templates

----Original Message Follows----
From: "Kenneth P. Turvey" <kt-usenet@squeakydolphin.com>
To: users@subversion.tigris.org
Subject: RE: pre-commit hook
Date: Sun, 26 Feb 2006 23:32:25 -0600
MIME-Version: 1.0
Received: from tigris.org ([64.125.133.100]) by
bay0-mc2-f12.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Sun, 26
Feb 2006 21:32:47 -0800
Received: (qmail 4161 invoked by uid 5000); 27 Feb 2006 05:32:35 -0000
Received: (qmail 4135 invoked from network); 27 Feb 2006 05:32:34 -0000
X-Message-Info: 6sSXyD95QpWq0gsNrap0B3paqIY3kjW6/EREgr6ldSc=
Mailing-List: contact users-help@subversion.tigris.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
list-help: <mailto:users-help@subversion.tigris.org>
list-unsubscribe: <mailto:users-unsubscribe@subversion.tigris.org>
list-post: <mailto:users@subversion.tigris.org>
Delivered-To: mailing list users@subversion.tigris.org
X-Injected-Via-Gmane: http://gmane.org/
Lines: 112
References: <BF2B9DC61A29D74A89B6339222F8B434048230FE@mundi.radius.ad>
X-Complaints-To: usenet@sea.gmane.org
X-Gmane-NNTP-Posting-Host: 71-11-134-4.dhcp.stls.mo.charter.com
User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table (Debian
GNU/Linux))
PGP-Key: 0xB4D42E3A
ICBM: +38.5536,-89.9351
Return-Path: users-return-45649-pons32=hotmail.com@subversion.tigris.org
X-OriginalArrivalTime: 27 Feb 2006 05:32:47.0811 (UTC)
FILETIME=[3E332930:01C63B5F]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 27 Feb 2006 00:20:55 -0500, Rob van Oostrum wrote:

> Where are you looking for the echo? The echo will not show up
> client-side because the script is called by the server process.
>
> Information about your OS etc would help. Also, could you provide shell
> output. For example, 'ls -l' on the hooks dir, as well as the contents
> of your pre-commit script.

I'm running Linux. There isn't any server. I'm running against a local
repository. The URL I'm using is:

file:///home/kt/subversion/WhateverDirectory

This is really just experimental. Please don't spend much time on it.

The hooks directory looks like this:

kt@volkswagon:~/subversion/hooks$ ls -l *
- -rwxr-x--- 1 kt kt 1993 2006-02-05 23:00 post-commit.tmpl
- -rwxr-x--- 1 kt kt 1648 2006-02-05 23:00 post-lock.tmpl
- -rwxr-x--- 1 kt kt 2287 2006-02-05 23:00 post-revprop-change.tmpl
- -rwxr-x--- 1 kt kt 1575 2006-02-05 23:00 post-unlock.tmpl
- -rwxr-xr-x 1 kt kt 1599 2006-02-26 23:05 pre-commit
- -rwxr-x--- 1 kt kt 2966 2006-02-05 23:00 pre-commit.tmpl
- -rwxr-x--- 1 kt kt 2009 2006-02-05 23:00 pre-lock.tmpl
- -rwxr-x--- 1 kt kt 2763 2006-02-05 23:00 pre-revprop-change.tmpl
- -rwxr-x--- 1 kt kt 1988 2006-02-05 23:00 pre-unlock.tmpl
- -rwxr-x--- 1 kt kt 2136 2006-02-05 23:00 start-commit.tmpl
kt@volkswagon:~/subversion/hooks$

The script is unchanged from an archive of one of the subversion mailing
lists and is intended to prevent commits to the tags directory.

#!/bin/sh
########################
# repository
########################
REPOS="$1"
# Transaction
TXN="$2"
########################
#debug
########################
#transaction=`$SVNLOOK changed -t $TXN $REPO`
#echo "$transaction";
echo This should be printed out
##########################
# user 'god' can do anything
##########################
# User=`svnlook author -t $TXN $REPOS`
# if ( $User == "god" ){ exit 0 }
#################################
# Log message contains some text.
#################################
SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
    grep "[a-zA-Z0-9]" > /dev/null || exit 1
########################
# Protect tags directory
########################
# Deny transaction if any line writes to tags directory that exists.
# tags dir match pattern
TAGS_REGEX='tags/[^/]\+'
# Get list of transactions in the 'tag' directory
TAGS_CHANGES=`"$SVNLOOK" changed -t "$TXN" "$REPOS" 2>/dev/null | \
                  awk '{ print $2; }' 2>/dev/null | \
                  grep ^tags/ 2>/dev/null | \
                  sed -e "s!^\($TAGS_REGEX\).*!\1!" | \
                  sort | \
                  uniq`
# Get head revision number
YOUNGEST=`svnlook youngest "$REPOS" 2>/dev/null`
# For every line in transaction,
# check to see if directory in tags exists
for CHANGE in $TAGS_CHANGES; do
   # If directory in tags exists, deny transaction
   if svnlook proplist -r $YOUNGEST "$REPOS" "$CHANGE" >/dev/null 2>&1 ;
then
     echo "Cannot modify existing tag: ${tag}" >&2
     exit 1
   fi
done
#######################
# Allow transaction
#######################
exit 0

Thank you,

- --
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>
Phone : (314) 255-2199

XMPP IM: kpturvey@jabber.org
Yahoo IM: kpturvey2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEAo7hi2ZgbrTULjoRAhkrAJ9YKZBwKgK2yuVZMjZSh5h2/Nn2JQCaA1CC
ScOV8DLpuWzzRHYnKuGsl40=
=nmnJ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Tue Feb 28 19:35:43 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.