Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Last active June 6, 2019 09:23
Show Gist options
  • Save dongyuwei/0ed46c8dc30d5ab72ff02bb2a58879fe to your computer and use it in GitHub Desktop.
Save dongyuwei/0ed46c8dc30d5ab72ff02bb2a58879fe to your computer and use it in GitHub Desktop.

上次培训有人问git bisect这个命令怎么应用,今天查了一下文档并实际动手练习了一下,如果项目有自动化测试,那么使用起来就比较简单了, 比如:

  1. git bisect start master 2f381c3 master 也可以是特定的commit rev
  2. git bisect run node test.js

很快就可以自动定位是哪个 commit让测试挂了。

但如果没有自动化测试,或者自动化测试覆盖不全,或者测试运行很慢(如e2e)测试,那么可能就需要人工介入,git bisect还有很多半自动化的运行模式,使用起来稍微复杂一些。

Math.log2(100) == 6.6, 100个commits只需要跑7次测试就可以找到bad commit。问题就是每次测试需要多久了。每次10分钟也需要70分钟了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment