Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JENKINS-70331: Always honor useExistingAccountWithSameEmail #1382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/hudson/plugins/git/GitChangeSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,14 @@ public User findOrCreateUser(String csAuthor, String csAuthorEmail, boolean crea
}
}
} else {
if (useExistingAccountWithSameEmail && hasMailerPlugin()) {
for(User existingUser : User.getAll()) {
if (csAuthorEmail.equalsIgnoreCase(getMail(existingUser))) {
return existingUser;
}
}
}

if (csAuthor.isEmpty()) {
// Avoid exception from User.get("", false)
return User.getUnknown();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/hudson/plugins/git/GitChangeSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void testFindOrCreateUserBasedOnExistingUsersEmail() throws IOException {
final String existingUserId = "An existing user";
final String existingUserFullName = "Some FullName";
final String email = "[email protected]";
final boolean createAccountBasedOnEmail = true;
final boolean createAccountBasedOnEmail = random.nextBoolean();
final boolean useExistingAccountBasedOnEmail = true;

assertNull(User.get(email, false));
Expand Down