What I learned today — 14 February 2018
Tracking down a bad commit with git bisect
and a script
Today I had to track down the commit in which an obscure bug was introduced, which made our Angular build fail when using ahead-of-time compilation.
With git bisect
you can track down a bad commit using a binary search between a known good and a known bad commit. This can be automated with a script that returns an exit code of 0 on a good build, and between 1 and 127 (inclusive), except 125, on a bad commit. 125 is used to indicate that a version of the source code could not be tested. This is how to do it:
# HEAD is a bad commit, and 494fc3a6 is good
git bisect start HEAD 494fc3a6
git bisect run ./script.sh
After happily running for a while, git will narrow down the bad commit. In our case it was related to Angular#18170, and an export in index.ts
. The solution, for us, was to import the enum with it’s own relative path, rather than using the export in index.ts
.