Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 51 lines (40 sloc) 0.957 kb
9527072 @garybernhardt add run-command-on-git-revisions script
authored
1 #!/bin/bash
2 #
3 # This script runs a given command over a range of Git revisions. Note that it
4 # will check past revisions out! Exercise caution if there are important
5 # untracked files in your working tree.
1512d2f @garybernhardt add attribution to run-command-on-git-revisions
authored
6 #
7 # This came from Gary Bernhardt's dotfiles:
8 # https://github.com/garybernhardt/dotfiles
9527072 @garybernhardt add run-command-on-git-revisions script
authored
9
10 set -e
11
12 start_ref=$1
13 end_ref=$2
14 test_command=$3
15
16 main() {
17 enforce_usage
18 run_tests
19 }
20
21 enforce_usage() {
22 if [ -z "$test_command" ]; then
23 usage
24 exit $E_BADARGS
25 fi
26 }
27
28 usage() {
29 echo "usage: `basename $0` start_ref end_ref test_command"
30 }
31
32 run_tests() {
33 revs=`log_command git rev-list --reverse ${start_ref}..${end_ref}`
34
35 for rev in $revs; do
36 echo "Checking out: $(git log --oneline -1 $rev)"
37 log_command git checkout --quiet $rev
38 log_command $test_command
39 done
40 log_command git checkout $end_ref
41 echo "OK for all revisions!"
42 }
43
44 log_command() {
45 echo "=> $*" >&2
46 $*
47 }
48
49 main
50
Something went wrong with that request. Please try again.