forked from tv42/gitbuilder
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext-rev.sh
executable file
·48 lines (43 loc) · 1.09 KB
/
next-rev.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
43
44
45
46
47
#!/bin/bash
DIR=$(dirname $0)
cd "$DIR/build"
bisect()
{
(git rev-list --first-parent --bisect-all "$@" ||
git rev-list --first-parent "$@" ) |
while read x y; do
[ -e ../out/pass/$x -o -e ../out/fail/$x ] && continue
echo $x
exit 0
done
}
../revlist.sh "$@" | (
pass=
fail=
pending=
while read commit junk; do
if [ -e ../out/pass/$commit ]; then
# only a maximum of one pass is ever received
pass=$commit
elif [ -e ../out/fail/$commit ]; then
# there might be more than one fail; we want the
# last one
fail=$commit
elif [ -z "$pending" -a -z "$fail" ]; then
# and we only want the first pending build,
# and only if it's *not* following a failed build
pending=$commit
fi
last=$commit
done
# if a pending build came before the first failed build, then we need to
# build it first.
if [ -n "$pending" ]; then
echo $pending
elif [ -n "$fail" -a -n "$pass" ]; then
bisect $fail^ ^$pass
elif [ -n "$fail" -a "$last" != "$fail" -a -n "$last" ]; then
bisect $fail^ ^$last
fi
# if we don't print anything at all, it means there's nothing to build!
)