[sysadmin-bin: 36/168] Add a pre-receive check for a MAINTAINERS file
- From: Andrea Veri <av src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin: 36/168] Add a pre-receive check for a MAINTAINERS file
- Date: Thu, 24 May 2012 19:54:28 +0000 (UTC)
commit 3bece93d4e5676e7bc6d71eca0375b86996dfb63
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Tue Mar 3 16:05:17 2009 -0500
Add a pre-receive check for a MAINTAINERS file
Add another pre-receive check that doesn't allow any commits to the
master branch (other than translator commits), unless there is a
proper MAINTAINERS file.
gnome-pre-receive | 4 +++
pre-receive-check-maintainers | 45 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/gnome-pre-receive b/gnome-pre-receive
index 3081db0..4c02f9a 100755
--- a/gnome-pre-receive
+++ b/gnome-pre-receive
@@ -21,6 +21,10 @@ while read oldrev newrev refname; do
# 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-maintainers $oldrev $newrev $refname ; then
+ exit 1
+ fi
+
if ! $BINDIR/pre-receive-check-po $oldrev $newrev $refname ; then
exit 1
fi
diff --git a/pre-receive-check-maintainers b/pre-receive-check-maintainers
new file mode 100755
index 0000000..0c3d9a2
--- /dev/null
+++ b/pre-receive-check-maintainers
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+check_maintainers() {
+ oldrev=$1
+ newrev=$2
+ refname=$3
+
+ branchname=${refname#refs/heads/}
+ if [ "$branchname" = "$refname" ] ; then
+ # not a branch update
+ return 0
+ fi
+
+ if [ "$branchname" != "master" ] ; then
+ # MAINTAINERS only required on the master branch
+ return 0
+ fi
+
+ if expr $oldrev : "^0+$" > /dev/null 2>&1; then
+ # Don't require MAINTAINERS for initial imports; keeps things simple
+ return 0
+ fi
+
+ if ! git diff-tree --name-only -r $oldrev $newrev | grep -q -v '\(LINGUAS\|ChangeLog\|.po\)$' ; then
+ # Looks like something a translator would do, exempt it from the check
+ return 0
+ fi
+
+ if ! git cat-file blob $newrev:MAINTAINERS 2>/dev/null | /bin/grep -q "^Userid:" ; then
+ echo "A valid MAINTAINERS file is required. See http://live.gnome.org/MaintainersCorner#maintainers" >&2
+ return 1
+ fi
+}
+
+if [ $# = 3 ] ; then
+ if ! check_maintainers $@ ; then
+ exit 1
+ fi
+else
+ while read oldrev newrev refname; do
+ if ! check_maintainers $oldrev $newrev $refname ; then
+ exit 1
+ fi
+ done
+fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]