aboutsummaryrefslogtreecommitdiff
path: root/local/bin/project-test
blob: e8c6261ee776dbbd4469299a5d57a799dd7ef931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Executes given command on all commits from current one to given one.
set -e

print_help() {
	echo "Executes given command for each commit. In default it executes"
	echo "for 10 previous commands."
	echo
	echo "Usage: project-test [OPTION...] [--] COMMAND"
	echo "    -r,--ref [REF]"
	echo "        Git reference to go to"
	echo "    -c,--count [COUNT]"
	echo "        Tests given count of references back from current one."
}

while [ -n "$1" ]; do
	case $1 in
		-r|--ref)
			shift
			REF=$1
			;;
		-c|--count)
			shift
			REF=HEAD~$1
			;;
		--)
			shift
			break
			;;
		*)
			break
			;;
	esac
	shift
done

[ -n "$REF" ] || REF=HEAD~10

while read -r rev; do
	git checkout "$rev"
	git submodule update
	eval "$@"
done < <(git rev-list "$REF"..HEAD)