An example of using phpunit in git-bisect, includes a wrapper.
PHP Shell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


What is git-bisect?

git-bisect is a command tool to help finding commits that change a good state.

How to use git-bisect?

This example uses git bisect in conjunction with phpunit to check when the testsuite breaks.

Define the “good” state

To define the “good” state, we choose phpunit. This is the testsuite run. If it fails, the commits state is “bad”.

Set up

The following commands will start the actual work with git-bisect.

  • git bisect start
  • git bisect bad

This will start the bisect search and mark the current version as “bad”.

Knowing the good version

  • git bisect good SHA1

This will mark the last known “good” state on the commit hash SHA1.

Automate it!

  • git bisect run ./

This will issue bisect to use the phpunit command line to check for a good state for each commit.
The script will wrap the exit codes of phpunit to the correct ones to operate with git-bisect.

Try-it Out

Using this project you can use these commands to actually test it.

  • git bisect start
  • git bisect bad #ABadCommitSha (HEAD is bad, so we can leave it out)
  • git bisect good 0fef4d40fec8ba1d1de73d8f13739e6c890e2223
  • git bisect run ./

The result will be this commit:b27af3d6ff6da22e02850d6e61d966db438847d7.