-
Notifications
You must be signed in to change notification settings - Fork 16
/
check-branch.sh
executable file
·42 lines (35 loc) · 1.13 KB
/
check-branch.sh
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
#/bin/sh
# check-branch.sh - Iterate over all new commits of a topic branch,
# recording whether the build passes or fails for each.
commits=$@
remote=$(git rev-parse --symbolic-full-name HEAD@{u})
remote=${remote#refs/remotes/}
remote=${remote%%/*}
headBranch=$(git remote show "$remote" | grep HEAD | sed 's/ *HEAD branch: //')
test "$commits" || commits=$(git rev-list HEAD "^$remote/$headBranch" | sed '1!G;h;$!d')
# NB: The sed line above reverses the order of the commits.
# See: http://stackoverflow.com/a/744093
branch=$(git rev-parse --abbrev-ref HEAD)
count=0
for commit in $commits
do
git checkout "$commit" > /dev/null 2>&1
mkdir -p tmp
prefix="$(printf %04d $count)"
filename="tmp/$prefix-$commit"
start=$(date +%s)
if [ -f Makefile ]
then
make test > "$filename" 2>&1 && result=SUCCESS || result=FAILURE
elif [ -f pom.xml ]
then
mvn clean verify > "$filename" 2>&1 && result=SUCCESS || result=FAILURE
else
result=SKIPPED
fi
end=$(date +%s)
time=$(expr "$end" - "$start")
echo "$prefix $commit $result $time"
count=$(expr "$count" + 1)
done
git checkout "$branch" > /dev/null 2>&1