Ignore new line differences when deciding whether to squash MR
What does this MR do and why?
Attempts to ease problems outlined in #349399 (closed).
In !74464 (merged), I've allowed squashing single commit MR to make squash commit template apply to them. To allow preserving untouched commit without squashing for single commit MRs, the exact same squash commit message as the already existing single commit message has to be used when merging. However, user noticed that this doesn't work reliably. It looks like it is due to new line differences - git normalizes messages, and adds a trailing new line. However, we're comparing commit message to the one sent from form, which is not yet normalized through git, so sometimes they don't match and the squash is performed. In my tests, it would typically be the lack of trailing new line.
In this MR, I propose stripping both commit messages when comparing them, to ignore those differences.
Screenshots or screen recordings
The change is backend-only.
How to set up and validate locally
- Use squash commit template: "
%{first_commit}
" in project. - Create a MR with a single commit.
- Squash merge MR.
- Confirm that the resulting commit has the same sha as the commit in MR.
- Attempt the same with added trailing new line in commit message, confirm that the sha doesn't differ after the merge.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.