Git bisect for a gem dependency?

91 views Asked by At

I have Ruby gem with tests, and it has a dependency on another gem.

Recently there was a new release of that other gem, which broke my gem's test suite due to a change in behaviour.

I know which minor version bump of the other gem is to blame, but I want to find out the exact commit (there are several hundred commits between the point releases) so that I can understand where the problem is.

I've used git bisect before to narrow down a bad commit in my repo, but can I do something similar for a dependency?

1

There are 1 answers

0
Frederick Cheung On

You can do this with a little fiddling:

  1. Clone the repo for the gem locally
  2. Update your gemfile to fetch the gem from git, making sure that you specify a branch
  3. In your app's directory run

    bundle config --local local.mygem path/to/checkout
    

Your app should now be loading that gem from your checkout and you should be able to run git bisect on that repo. Things like zeus, spring may need to be restarted after each revision is checked out - they tend to watch gemfile.lock so may not notice if the gem itself changes.

When you are done, revert the change to your gemfile and edit .bundle/config to remove the override.