Skip to content

Commit

Permalink
[FIXED JENKINS-12279] Link to user profile from console output should…
Browse files Browse the repository at this point in the history
… go to the user ID, not the

user name
  • Loading branch information
ssogabe committed Jan 3, 2012
1 parent 2ac1df4 commit cae5d74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -61,6 +61,9 @@
<li class='rfe'>
Reduced overhead of maven jobs.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-11883">issue 11883</a>)
<li class=bug>
Link to user profile from console output should go to the user ID, not the user name
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-12279">issue 12279</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
26 changes: 13 additions & 13 deletions core/src/main/java/hudson/model/Cause.java
Expand Up @@ -36,7 +36,7 @@
import com.thoughtworks.xstream.converters.UnmarshallingContext;

/**
* Cause object base class. This class hierarchy is used to keep track of why
* Cause object base class. This class hierarchy is used to keep track of why
* a given build was started. This object encapsulates the UI rendering of the cause,
* as well as providing more useful information in respective subypes.
*
Expand Down Expand Up @@ -89,13 +89,13 @@ public static class LegacyCodeCause extends Cause {
public LegacyCodeCause() {
stackTrace = new Exception().getStackTrace();
}

@Override
public String getShortDescription() {
return Messages.Cause_LegacyCodeCause_ShortDescription();
}
}

/**
* A build is triggered by the completion of another build (AKA upstream build.)
*/
Expand All @@ -116,7 +116,7 @@ public static class UpstreamCause extends Cause {
public UpstreamCause(AbstractBuild<?,?> up) {
this((Run<?,?>)up);
}

public UpstreamCause(Run<?, ?> up) {
upstreamBuild = up.getNumber();
upstreamProject = up.getParent().getFullName();
Expand Down Expand Up @@ -152,7 +152,7 @@ public int getUpstreamBuild() {
public String getUpstreamUrl() {
return upstreamUrl;
}

@Override
public String getShortDescription() {
return Messages.Cause_UpstreamCause_ShortDescription(upstreamProject, upstreamBuild);
Expand Down Expand Up @@ -182,7 +182,7 @@ public static class ConverterImpl extends XStream2.PassthruConverter<UpstreamCau

/**
* A build is started by an user action.
*
*
* @deprecated 1.428
* use {@link UserIdCause}
*/
Expand Down Expand Up @@ -217,13 +217,13 @@ public int hashCode() {

/**
* A build is started by an user action.
*
*
* @since 1.427
*/
public static class UserIdCause extends Cause {

private String userId;

public UserIdCause() {
User user = User.current();
this.userId = (user == null) ? null : user.getId();
Expand All @@ -233,13 +233,13 @@ public UserIdCause() {
public String getUserId() {
return userId;
}

@Exported(visibility = 3)
public String getUserName() {
String userName = "anonymous";
if (userId != null) {
User user = User.get(userId, false);
if (user != null)
if (user != null)
userName = user.getDisplayName();
}
return userName;
Expand All @@ -249,13 +249,13 @@ public String getUserName() {
public String getShortDescription() {
return Messages.Cause_UserIdCause_ShortDescription(getUserName());
}

@Override
public void print(TaskListener listener) {
listener.getLogger().println(Messages.Cause_UserIdCause_ShortDescription(
HyperlinkNote.encodeTo("/user/"+getUserName(), getUserName())));
HyperlinkNote.encodeTo("/user/"+getUserId(), getUserName())));
}

@Override
public boolean equals(Object o) {
return o instanceof UserIdCause && Arrays.equals(new Object[]{userId},
Expand Down

0 comments on commit cae5d74

Please sign in to comment.