[ghns] Fwd: r397 - trunk/hotstuff/scripts
Josef Spillner
spillner at kde.org
Sun Dec 9 02:02:30 PST 2007
Hi there,
the pre-commit hook added below (and r398 which added the corresponding
schema) can be used to verify *.meta files before they're added to SVN. The
script isn't installed at data.kstuff.org yet but I could do that soon. An
improvements would be to use xmlstarlet to get the preview/payload file paths
and check if those files exist, although this requires more than svnlook
since they might have been committed earlier already.
Josef
---------- Yönlendirilmiş İleti ----------
Konu: r397 - trunk/hotstuff/scripts
Tarih: Pazar 09 Aralık 2007
Gönderen: josef at kdeget.osuosl.org
Kime: josef at kstuff.org
Author: josef
Date: 2007-12-09 09:59:09 +0000 (Sun, 09 Dec 2007)
New Revision: 397
Added:
trunk/hotstuff/scripts/pre-commit
Log:
- pre-commit hook script for *.meta files
Added: trunk/hotstuff/scripts/pre-commit
===================================================================
--- trunk/hotstuff/scripts/pre-commit (rev 0)
+++ trunk/hotstuff/scripts/pre-commit 2007-12-09 09:59:09 UTC (rev 397)
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# GHNS pre-commit hook for meta file validation in a SVN-backed repository
+# Copyright (C) 2007 Josef Spillner <josef at kstuff.org>
+# Published under GNU GPL conditions
+
+# Read in parameters
+REPOS="$1"
+TXN="$2"
+
+# Change to line-based processing
+IFS="
+"
+
+# Assign values for temporary file locations
+diff=~/.ghnsmeta.$$.diff
+cat=~/.ghnsmeta.$$.cat
+
+# Examine files: we're only interested in '*.meta'
+changes=`svnlook changed -t $TXN $REPOS | grep "\.meta"`
+for change in $changes; do
+ # Get the previous version (might be empty) and the patch
+ mod=`echo $change | awk '{print $1}'`
+ file=`echo $change | awk '{print $2}'`
+ svnlook diff -t $TXN $REPOS | filterdiff -i "$file" > $diff
+ svnlook cat $REPOS "$file" > $cat 2>/dev/null
+
+ # Apply the requested changes to files
+ patch $cat $diff
+
+ # Shortcut for deletions
+ lines=`wc -l $cat | awk '{print $1}'`
+ if [ $lines = 0 ]; then
+ continue
+ fi
+
+ # Run XML validation first
+ out=`xmllint --noout $cat 2>&1`
+ if [ $? != 0 ]; then
+ echo "----------------------------" >&2
+ echo "** GHNS validation failed **" >&2
+ echo "Reason: Invalid XML in $file" >&2
+ echo "----------------------------" >&2
+ echo $out >&2
+ exit 1
+ fi
+
+ # Run XML schema validation
+ out=`xmllint --schema /etc/xml/ghns.xsd --noout $cat 2>&1`
+ if [ $? != 0 ]; then
+ echo "----------------------------" >&2
+ echo "** GHNS validation failed **" >&2
+ echo "Reason: Non-conforming upload XML in $file" >&2
+ echo "----------------------------" >&2
+ echo $out >&2
+ exit 1
+ fi
+done
+
+exit 0
Property changes on: trunk/hotstuff/scripts/pre-commit
___________________________________________________________________
Name: svn:executable
+ *
-------------------------------------------------------
More information about the ghns
mailing list