feat: Respect user-defined Git author identity in merges#3946
Open
KrasimirAntonov wants to merge 2 commits intojenkinsci:masterfrom
Open
feat: Respect user-defined Git author identity in merges#3946KrasimirAntonov wants to merge 2 commits intojenkinsci:masterfrom
KrasimirAntonov wants to merge 2 commits intojenkinsci:masterfrom
Conversation
added 2 commits
April 2, 2026 12:48
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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