Skip to content
Browse files

add run-command-on-git-revisions script

  • Loading branch information...
1 parent cef0809 commit 952707275177ab44608e7ff560a5e268709555a5 @garybernhardt committed Dec 8, 2010
Showing with 47 additions and 0 deletions.
  1. +47 −0 bin/run-command-on-git-revisions
View
47 bin/run-command-on-git-revisions
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# This script runs a given command over a range of Git revisions. Note that it
+# will check past revisions out! Exercise caution if there are important
+# untracked files in your working tree.
+
+set -e
+
+start_ref=$1
+end_ref=$2
+test_command=$3
+
+main() {
+ enforce_usage
+ run_tests
+}
+
+enforce_usage() {
+ if [ -z "$test_command" ]; then
+ usage
+ exit $E_BADARGS
+ fi
+}
+
+usage() {
+ echo "usage: `basename $0` start_ref end_ref test_command"
+}
+
+run_tests() {
+ revs=`log_command git rev-list --reverse ${start_ref}..${end_ref}`
+
+ for rev in $revs; do
+ echo "Checking out: $(git log --oneline -1 $rev)"
+ log_command git checkout --quiet $rev
+ log_command $test_command
+ done
+ log_command git checkout $end_ref
+ echo "OK for all revisions!"
+}
+
+log_command() {
+ echo "=> $*" >&2
+ $*
+}
+
+main
+

0 comments on commit 9527072

Please sign in to comment.
Something went wrong with that request. Please try again.