Skip to content

Commit

Permalink
Dev/adelcast/fix author (#188)
Browse files Browse the repository at this point in the history
* TfsUserLookup.find: fix logging message

Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>

* tfs: use owner instead of commiter as author

It is not uncommon to have automatic processes to merge between
branches, run validation before submission, etc. When that happens, the
submitter may be different than the owner (the submitter tends to be an
account used for automation). In those cases, the Jenkins UI will show
the same name for all commits. Use owner name instead, as it better
reflects the name of the person that authored the commit.

Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
  • Loading branch information
Alejandro del Castillo authored and jpricket committed Jan 4, 2018
1 parent 739a6ac commit 526a5a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Integer call() throws Exception {
final Changeset serverChangeset = serverChangeSets[0];
changeSetNumber = serverChangeset.getChangesetID();
final Date changeSetDate = serverChangeset.getDate().getTime();
final String author = serverChangeset.getCommitter();
final String author = serverChangeset.getOwner();
final SimpleDateFormat simpleDateFormat = DateUtil.TFS_DATETIME_FORMATTER.get();
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
final String changeSetDateIso8601 = simpleDateFormat.format(changeSetDate);
Expand Down
2 changes: 1 addition & 1 deletion tfs/src/main/java/hudson/plugins/tfs/model/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public String getProjectPath() {
(com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Changeset serverChangeset, UserLookup userLookup) {
final String version = Integer.toString(serverChangeset.getChangesetID(), 10);
final Date date = serverChangeset.getDate().getTime();
final String author = serverChangeset.getCommitter();
final String author = serverChangeset.getOwner();
final User authorUser = userLookup.find(author);
final String comment = serverChangeset.getComment();

Expand Down
4 changes: 2 additions & 2 deletions tfs/src/main/java/hudson/plugins/tfs/model/TfsUserLookup.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public TfsUserLookup(final IIdentityManagementService ims, final UserAccountMapp
*/
public User find(final String accountName) {
final String mappedAccountName = userAccountMapper.mapUserAccount(accountName);
logger.log(Level.FINE, "Looking up Jenkins user for account '%s'.", mappedAccountName);
logger.log(Level.FINE, String.format("Looking up Jenkins user for account '%s'.", mappedAccountName));
final User jenkinsUser = User.get(mappedAccountName);
Mailer.UserProperty mailerProperty = jenkinsUser.getProperty(Mailer.UserProperty.class);
if (mailerProperty == null || mailerProperty.getAddress() == null || mailerProperty.getAddress().length() == 0) {
logger.log(Level.FINE, "No Mailer.UserProperty defined for '%s', looking in TFS", mappedAccountName);
logger.log(Level.FINE, String.format("No Mailer.UserProperty defined for '%s', looking in TFS", mappedAccountName));
final TeamFoundationIdentity tfsUser = ims.readIdentity(
IdentitySearchFactor.ACCOUNT_NAME,
accountName,
Expand Down

0 comments on commit 526a5a0

Please sign in to comment.