[sysadmin-bin: 35/168] Add a port of the svn pre-commit .po file check
- From: Andrea Veri <av src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin: 35/168] Add a port of the svn pre-commit .po file check
- Date: Thu, 24 May 2012 19:54:23 +0000 (UTC)
commit b6cc3e8656fd96e26da8fd2a5e9acec7d65d8cf7
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Tue Mar 3 15:15:55 2009 -0500
Add a port of the svn pre-commit .po file check
pre-receive-check-po: Port of the .po-file checking script used
for svn.
gnome-pre-receive: Wrapper pre-receive hook along the lines of
gnome-post-receive. This is the pre-receive hook for all modules.
gnome-pre-receive | 27 ++++++++++++
pre-receive-check-po | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 136 insertions(+), 0 deletions(-)
---
diff --git a/gnome-pre-receive b/gnome-pre-receive
new file mode 100755
index 0000000..3081db0
--- /dev/null
+++ b/gnome-pre-receive
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# Standard GNOME pre-receive hook.
+#
+# The "pre-receive" hook is invoked just before receive-pack starts to
+# update refs on the remote repository. Its exit status determines the
+# success or failure of the update.
+
+BINDIR=/home/admin/gitadmin-bin
+
+# If the committing user has a homedir with a .gitconfig in it, it we
+# don't want that to affect our operation. (Should this just be handled
+# in run-git-or-special-cmd?)
+GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
+GIT_CONFIG="${GIT_DIR}/config"
+export GIT_CONFIG
+
+while read oldrev newrev refname; do
+ # Unlike the gnome-post-receive script, where we play fancy games
+ # with 'tee', we invoke the different pre-receive hooks separately
+ # for each ref that is updated. This keeps things simple and
+ # reliable and none of the scripts need all the refs at once.
+
+ if ! $BINDIR/pre-receive-check-po $oldrev $newrev $refname ; then
+ exit 1
+ fi
+done
diff --git a/pre-receive-check-po b/pre-receive-check-po
new file mode 100755
index 0000000..e6db14b
--- /dev/null
+++ b/pre-receive-check-po
@@ -0,0 +1,109 @@
+#!/bin/bash
+
+check_pos() {
+ oldrev=$1
+ newrev=$2
+ refname=$3
+
+ branchname=${refname#refs/heads/}
+ if [ "$branchname" = "$refname" ] ; then
+ # not a branch update
+ return
+ fi
+
+ branch_message=
+ if [ "x$branchname" != "master" ] ; then
+ branch_message=" (When updating branch '$branchname'.)"
+ fi
+
+ git diff-tree -r $oldrev $newrev | (
+ while read srcmode destmode srcsha destsha status srcpath destpath ; do
+ if [ $status = 'D' ] ; then
+ continue # deleted
+ fi
+
+ # destpath only present for copies/renames
+ if [ x"$destpath" = x ] ; then
+ destpath=$srcpath
+ fi
+
+ case "$destpath" in
+ *.po)
+ ;;
+ *)
+ continue
+ ;;
+ esac
+
+ basename=`basename $destpath`
+
+ # Strip colon from the source mode
+ srcmode=${srcmode#:}
+
+ # gettext-0.14.6 on git.gnome.org isn't new enough to handle
+ # features such as msgctx
+ # dash_c="-c"
+ dash_c=
+
+ # Parse the file and check for errors
+ result=`git cat-file blob "$newrev:$destpath" | msgfmt $dash_c -o /dev/null - 2>&1`
+ if [ $? -gt 0 ]; then
+ cat <<EOF >&2
+
+The following translation (.po) file appears to be invalid.$branch_message
+
+$destpath
+
+The results of the validation follow. Please correct the errors on the line numbers mentioned and try to push again.
+
+$result
+
+To check this locally before attempting to push again, you can use the following command:
+
+msgfmt $dash_c $basename
+
+After making fixes, modify your commit to include them, by doing:
+
+git add $basename
+git commit --amend
+
+If you have any further problems or questions, please contact the GNOME Translation Project mailing list <gnome-i18n gnome org>. Thank you.
+
+EOF
+ exit 1
+ fi
+
+ # Check for the absence of an executable flag
+ if expr "$destmode" : ".*\([1357]..\|[1357].\|[1357]\)$" > /dev/null 2>& 1; then
+ cat <<EOF >&2
+
+The following translation file appears to have its executable flag set.$branch_message
+
+$destpath
+
+Translation files should not be executable. Please remove the flag and try to push again. The following commands may help:
+
+chmod a-x $basename
+git add $basename
+git commit --amend
+
+If you have any further problems or questions, please contact the GNOME Translation Project mailing list <gnome-i18n gnome org>. Thank you.
+
+EOF
+ exit 1
+ fi
+ done
+ )
+}
+
+if [ $# = 3 ] ; then
+ if ! check_pos $@ ; then
+ exit 1
+ fi
+else
+ while read oldrev newrev refname; do
+ if ! check_pos $oldrev $newrev $refname ; then
+ exit 1
+ fi
+ done
+fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]