yankee yankee - 1 year ago 86
Git Question

How to run tests for all commits during a rebase

I have a feature branch with plenty of commits.

A---B---C master
\-B'---C'---D'...---Z' feature

I am working on
but another developer has created commits
. Now I want to rebase
on commit
, but I and/or automerge introduced errors during the rebase. My project has very good test coverage and I can run the tests from console using
ant rebuild test
, and now I want git to tell me which commit is the first commit that breaks my test so I can fix that commit. How can I do that?

Answer Source

While you are on branch feature execute:

git rebase --interactive --exec "ant rebuild test" C

This will cause git to start again on commit C, replay your work on top and it will run your tests after each commit it applies during replay phase.

Hopefully your ant task will have a non-zero exit code if your tests fail. In this case git will stop as soon as the tests fail. You are immediately in the right position to amend you commit so that the tests will be happy again. After you have amended just execute git rebase --continue as usual and git will continue to check all you commits.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download