All commits should build
It's always pleasant to have every commits build on master, right? If you have to cherry pick one or if you have to checkout one commit, you are sure that the project still builds. It's pretty convenient.
But when you create a MR, in many cases only the differences of your branch are tested. However your git history is not tested.
Let's do it locally. You could use a pre-commit hook, but sometimes at the end of your day, you just want to save your work in a "wip commit" and don't want to struggle with the pre-commit hook.
So in the best case you will want to health check your git history when opening your pull request.
Git-rebase --exec to the rescue
Git is awesome. I am sure you already heard about git rebase, but do you know the --exec argument?
The goal of this argument is to execute a command between all the commits of your rebase. If the command fails then the rebase will stop on the faulty commit. Then you just have to amend the commit and continue the rebase. Pretty awesome isn't it?
How to use:
Here is what happen:
But what if there is an issue? If there is an issue, the rebase will stop on the faulty commit, and you will be able to fix it by usinggit commit --amend.Here is a demonstration, where I forgot a ; in one of my Rust file: