-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathnext-rev.sh
executable file
·66 lines (60 loc) · 1.73 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/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=
firstfail=
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, so that we can figure out where things
# started to go wrong.
fail=$commit
[ -n "$firstfail" ] || firstfail=$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 [ -n "$pending" ]; then
# if a pending build came before the first failed build,
# then we need to build it first.
echo "$pending"
elif [ -n "$fail" ]; then
# If there were no passing tests, just use the last one as
# a reference.
[ -n "$pass" ] || pass=$last
# First, we want to bisect to find the *last* failure before
# the first pass. That is, the commit where failures were
# introduced.
try=$(bisect "$fail^" "^$pass")
# But if there's nothing left to try (we tested it already),
# let's keep building the other commits in between, just in
# case one of the intermediate ones passes. (This can happen
# if commits are failing for two different reasons, sigh.)
if [ -z "$try" ]; then
try=$(bisect "$firstfail^" "^$pass")
fi
if [ -n "$try" ]; then
echo "$try"
fi
fi
# if we don't print anything at all, it means there's nothing to build!
)