avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject [37/43] avro git commit: AVRO-1841: Add clientside githooks to do basic commit validation
Date Sat, 14 May 2016 23:44:10 GMT
AVRO-1841: Add clientside githooks to do basic commit validation


Project: http://git-wip-us.apache.org/repos/asf/avro/repo
Commit: http://git-wip-us.apache.org/repos/asf/avro/commit/bd369baf
Tree: http://git-wip-us.apache.org/repos/asf/avro/tree/bd369baf
Diff: http://git-wip-us.apache.org/repos/asf/avro/diff/bd369baf

Branch: refs/heads/branch-1.8
Commit: bd369bafbfcecbfdda8666f5fadc4ddc44a8fcaf
Parents: 2ecd0a5
Author: Niels Basjes <nielsbasjes@apache.org>
Authored: Wed May 11 00:16:39 2016 +0200
Committer: Ryan Blue <blue@apache.org>
Committed: Sat May 14 16:43:07 2016 -0700

----------------------------------------------------------------------
 CHANGES.txt               |  2 ++
 build.sh                  |  8 +++++++-
 share/githooks/commit-msg | 43 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/avro/blob/bd369baf/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c33e743..bccaf17 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -40,6 +40,8 @@ Trunk (not yet released)
 
     AVRO-1840: Ensure that build.sh clean really cleans all generated files (nielsbasjes)
 
+    AVRO-1841: Add clientside githooks to do basic commit validation (nielsbasjes) 
+
   BUG FIXES
 
     AVRO-1493. Java: Avoid the "Turkish Locale Problem". Schema fingerprints are

http://git-wip-us.apache.org/repos/asf/avro/blob/bd369baf/build.sh
----------------------------------------------------------------------
diff --git a/build.sh b/build.sh
index 93654db..c0c31df 100755
--- a/build.sh
+++ b/build.sh
@@ -22,7 +22,7 @@ cd `dirname "$0"`     # connect to root
 VERSION=`cat share/VERSION.txt`
 
 function usage {
-  echo "Usage: $0 {test|dist|sign|clean|docker|rat}"
+  echo "Usage: $0 {test|dist|sign|clean|docker|rat|githooks}"
   exit 1
 }
 
@@ -235,6 +235,12 @@ UserSpecificDocker
       mvn test -Dmaven.main.skip=true -Dmaven.test.skip=true -DskipTests=true -P rat -pl
:avro-toplevel
       ;;
 
+    githooks)
+      echo "Installing AVRO git hooks."
+      cp share/githooks/* .git/hooks
+      find .git/hooks/ -type f | fgrep -v sample | xargs chmod 755
+      ;;
+
     *)
       usage
       ;;

http://git-wip-us.apache.org/repos/asf/avro/blob/bd369baf/share/githooks/commit-msg
----------------------------------------------------------------------
diff --git a/share/githooks/commit-msg b/share/githooks/commit-msg
new file mode 100644
index 0000000..07bbcc8
--- /dev/null
+++ b/share/githooks/commit-msg
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Client side pre-commit hook to assist the committers to ensure the commit messages
+# follow the chosen convention.
+
+LOGMESSAGE_FORMAT='^AVRO-[1-9][0-9]*: .*'
+COMMIT_MSG_FILE=$1
+
+echo "=========================="
+echo "Doing basic commit validation"
+
+echo -n "= Single line commit message: "
+COMMIT_LINES=$(cat ${COMMIT_MSG_FILE} | wc -l)
+if [ ${COMMIT_LINES} -eq 1 ];
+then
+  echo "Ok"
+else
+  echo "Fail: Found ${COMMIT_LINES} lines"
+  exit 1
+fi
+
+echo -n "= Commit message format: "
+if grep -q "${LOGMESSAGE_FORMAT}" ${COMMIT_MSG_FILE}
+then
+    echo "Ok"
+else
+    echo "Fail: Must be in this format: ${LOGMESSAGE_FORMAT}"
+    exit 1
+fi
+
+ISSUE_ID=$(head -1 ${COMMIT_MSG_FILE} | cut -d':' -f1)
+
+echo -n "= CHANGES.txt mentions ${ISSUE_ID}: "
+if grep -q "${ISSUE_ID}[^0-9]" CHANGES.txt
+then
+    echo "Ok"
+else
+    echo "Fail"
+    exit 1
+fi
+echo "=========================="
+
+exit 0


Mime
View raw message