feat: Respect user-defined Git author identity in merges#3946
feat: Respect user-defined Git author identity in merges#3946KrasimirAntonov wants to merge 2 commits intojenkinsci:masterfrom
Conversation
Ensures merge operations use the configured user identity if available, falling back to default values only when necessary. Improves consistency with user preferences and global configuration for commit metadata.
Introduces tests verifying that merge commit author information is set according to default, global config, or user extension. Ensures correct identity selection during merges and prevents regressions in commit attribution logic.
MarkEWaite
left a comment
There was a problem hiding this comment.
I'm not willing to accept this change into the plugin because I believe that merges should be performed in Pipeline scripts using command line git rather than relying on an freestyle jobs and an implementation inside the plugin.
|
Closing the pull request because I'm unwilling to accept changes in this area. |
|
Hi @MarkEWaite Just to clarify: what is the intended functionality of specifying user.name and user.email if they have no effect later in the pipeline execution? I’m trying to better understand the purpose of exposing these settings. Thanks. |
The custom user name / e-mail address is in the same condition as the merge extension. I don't plan to add anything to that area of the plugin. I won't remove it, because that would break some users, but I don't plan to modify it in the future. |
Description
Previously,
MergeWithGitSCMExtensionalways used hardcoded values"Jenkins" / "nobody@nowhere"as the author and committer of the merge commit, ignoring any user-configured identity.The
decorateRevisionToBuildmethod now resolves the identity in the following order:UserIdentityextension is configured in theGitSCM, it is applied viauserIdentity.decorate(scm, git).getGlobalConfigName()/getGlobalConfigEmail()), and only uses"Jenkins" / "nobody@nowhere"when those values arenull.Testing done
Three automated tests were added to
MergeWithGitSCMExtensionTest:testMergeCommitUsesDefaultIdentity— verifies that when no identity is configured, the merge commit is authored byJenkins / nobody@nowhere.testMergeCommitUsesGlobalConfigIdentity— setsglobalConfigName/globalConfigEmailon theGitSCMdescriptor and verifies the merge commit reflects those values.testMergeCommitUsesUserIdentityExtension— adds aUserIdentityextension to the SCM and verifies it takes precedence over the global config.All three tests build a real Jenkins freestyle project with a diverging branch scenario and inspect the HEAD commit's
PersonIdentvia JGit'sRevWalk.Submitter checklist