Commit committer name check with the commit author_name
What does this MR do and why?
Related to issue #375339 (closed) Related to MR !101909 (merged)
In this issue, the user wants a push rule to align the commit author in the git log with the user's account name in GitLab. In this MR, we use commiter_name to compare with GitLab account name, if so, the user can still push commit with author of another name.
But to prevent some cherry-pick or rebase commit from being blocked by validation, Now the logic is changed to compare committer's email and author's email first, and if they're the same, then compare the author's name with the GitLab user's name, and throw an error if the user names don't match. If the committer's email differs from the author's email, it is not checked. This avoids checking for a commit from cherry-pick or rebase.
/cc @prajnamas
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
- Enable feature flag
Feature.enable(:commit_committer_name_check_ff) - Get the output of
git config user.name, let's say its output isA. - Get the output of
git config user.email, let's say its output isa@gitlab.com. -
Project>Settings>Repository>Push rules, check theReject inconsistent user nameoption. https://docs.gitlab.com/ee/user/project/repository/push_rules.html#override-global-push-rules-per-project - Edit the
Full Nameof the current user to be different from the output of 1, for example,B. - Edit the
emailof the current user to be different from the output of 2, for example,a@gitlab.com. - Make some changes and push it to the current project.
- Since the
git config user.nameis inconsistent with theFull Nameof the current user, this push will be rejected.
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.