-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-bisect-master
executable file
·60 lines (39 loc) · 1.16 KB
/
git-bisect-master
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
#!/usr/bin/env sh
# Left commit
badCommit=$1
# Right commit
goodCommit=$2
echo '
Searching for the `master` branch based commits.
'
git bisect start "$badCommit" "$goodCommit"
echo '
Skipping the commits inside PRs...
'
totalCommitsNum=$(git rev-list --count "$goodCommit".."$badCommit")
prCommits=$(for commit in $(git rev-list "$goodCommit".."$badCommit" --merges --first-parent); do
git rev-list "$commit"^2 --not "$commit"^
done)
prCommitsNum=$(echo "$prCommits" | wc -l)
phaseCommitsNum=$(( ("$totalCommitsNum" / 2) - "$prCommitsNum" ))
phaseSteps=$(echo "sqrt($phaseCommitsNum) + 1" | bc)
echo "$prCommits" | xargs git bisect skip
echo "
NOTE: Git does not account for the skipped comments in its counters, there is less revisions and steps to bisect than it reports.
This Phase works in $phaseCommitsNum commits, it is ~$phaseSteps steps in this phase.
Skipped $prCommitsNum commits inside PRs.
"
echo '
+====
1. Finish Phase 1 with the classical:
```sh
git bisect run <test-command>
# OR
git bisect bad/good
```
Phase 1 results in particular PR / `master` branch commit.
2. Phase 2:
```sh
git-bisect-pr <commit>
```
'