[PATCH] devel: add script to run tests on a patch series.

david at tethera.net david at tethera.net
Mon Dec 24 05:47:33 PST 2012


From: David Bremner <bremner at debian.org>

This script is a thin wrapper around git rebase --interactive, that
allows the user to fine tune patches if they break the test suite, or
violate the coding style guidelines.

The user can always run "git rebase --continue" to ignore false positives.

I decided to use perl because inplace editing with sed is non-portable.
---

I have caught several formatting violations and at least one real bug 
using this as "last step before sending to the list".

No doubt the more talented shell-scripters / perl-hackers in the crowd
can can suggest some improvements.

 devel/check-commit |   10 ++++++++++
 devel/check-series |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100755 devel/check-commit
 create mode 100755 devel/check-series

diff --git a/devel/check-commit b/devel/check-commit
new file mode 100755
index 0000000..86648b8
--- /dev/null
+++ b/devel/check-commit
@@ -0,0 +1,10 @@
+# This script is mainly intended to be used by the check-series script
+# but you are welcome to use it as a standalone tool. It takes no
+# parameters and operates on the latest git commit (HEAD).
+
+set -e
+make test
+for file in $(git diff --name-only HEAD^ | grep '[.]\(c\|h\|cc\|hh\)'); do
+    uncrustify --replace -c devel/uncrustify.cfg $file
+done
+git diff --quiet
diff --git a/devel/check-series b/devel/check-series
new file mode 100755
index 0000000..d48e70f
--- /dev/null
+++ b/devel/check-series
@@ -0,0 +1,33 @@
+#/bin/sh
+
+# Usage: check-series [upstream-commit]
+
+# Checks each commit in a patch series (topic branch) by running the
+# script devel/check-commit. If check-commit fails (exits with
+# non-zero status), the user is left in the middle of a git rebase, and
+# can fix the commit, e.g. using git commit --amend, followed by
+# "git rebase --continue". If all else fails, "git rebase --abort" should
+# get you back to where you started.
+#
+# NOTE: this runs "make test" many times, so it can take a while.
+#
+
+trap cleanup EXIT
+
+cleanup () {
+    if [ -n "$tmpdir" ]; then
+	rm -rf $tmpdir
+    fi
+}
+
+upstream=master
+if [ -n "$1" ]; then
+    upstream="$1"
+fi
+
+# make sure we always run the most recent version of check-commit
+# in particular cope with it going away.
+tmpdir=$(mktemp -d)
+cp devel/check-commit $tmpdir
+
+GIT_SEQUENCE_EDITOR="perl -pi -e 's,^\s*([^#\s].*)$,\1\nexec $tmpdir/check-commit,'" git rebase -i $upstream
-- 
1.7.10.4



More information about the notmuch mailing list