Check push rules against all commits that have diverged before merging
Description
- Check push rules against all commits that have diverged in the merge request when attempting to merge it.
- In particular, check only the commits that are in the commits tab of the merge request.
- If any of the commits fails any push rules of the target branch's project, then stop the merge.
- Pending some UI flow to indicate the merge failed.
Original description
Zendesk: https://gitlab.zendesk.com/agent/tickets/50264
A customer has been able to reliably reproduce an issue where a merge request can be accepted despite the commit message not conforming to the commit message push rule. They also reproduced it on GitLab.com in their own test project (and I confirmed this is true myself), but I cannot reproduce the same issue in my own test project.
Here are the steps to reproduce (sometimes):
- Commit to a branch when the Push Rule is disabled
- Add the
<log>.*<\/log>
push rule. This is the exact regex the customer is using - unsure if it's relevant as I couldn't reproduce outside their test project. - Turn on approvals for the project. (This may or may not be relevant, also - but including here for posterity)
- Approve the merge request.
- Attempt to merge the merge request.
When reproducible, the 5th step would result in a successful merge.
The customer has created a test project where we can see/reproduce the issue at jogux/commitmessagetest!3 (merged).
Edited by Victor Wu