Skip to content

Commit

Permalink
Only set email if User's address in null or empty.
Browse files Browse the repository at this point in the history
JENKINS-28421
  • Loading branch information
p4paul committed Aug 19, 2015
1 parent 6983371 commit e117cd2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/java/org/jenkinsci/plugins/p4/changes/P4ChangeEntry.java
Expand Up @@ -11,6 +11,7 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import org.jenkinsci.plugins.p4.client.ConnectionHelper;
import org.kohsuke.stapler.export.Exported;
Expand All @@ -24,6 +25,9 @@

public class P4ChangeEntry extends ChangeLogSet.Entry {

private static Logger logger = Logger.getLogger(P4ChangeEntry.class
.getName());

private int FILE_COUNT_LIMIT = 50;

private Object id;
Expand Down Expand Up @@ -62,9 +66,14 @@ public void setChange(ConnectionHelper p4, int changeId) throws Exception {
author = User.get(user);

// set email property on user
String email = p4.getEmail(user);
UserProperty userProp = new UserProperty(email);
author.addProperty(userProp);
UserProperty prop = author.getProperty(UserProperty.class);
if (prop == null || prop.getAddress() == null
|| prop.getAddress().isEmpty()) {
String email = p4.getEmail(user);
UserProperty userProp = new UserProperty(email);
author.addProperty(userProp);
logger.fine("Setting email for user: " + user + ":" + email);
}

// set date of change
date = changelist.getDate();
Expand Down

0 comments on commit e117cd2

Please sign in to comment.