Skip to content

Commit

Permalink
Merge pull request #4 from kutzi/master
Browse files Browse the repository at this point in the history
Include revisions also for non-subversion plugins; include revisions also if we don't have a repository browser
  • Loading branch information
olamy committed Aug 25, 2011
2 parents da0c79a + 149fe1e commit 48c55e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.403</version>
<version>1.405</version>
</parent>

<artifactId>jira</artifactId>
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/hudson/plugins/jira/Updater.java
Expand Up @@ -131,10 +131,14 @@ static void submitComments(
StringBuilder aggregateComment = new StringBuilder();
for(Entry e :build.getChangeSet()){
if(e.getMsg().toUpperCase().contains(issue.id)){
aggregateComment.append(e.getMsg()).append("\n");
// kutzi: don't know why the issue id was removed in previous versions:
//aggregateComment = aggregateComment.replaceAll(id, "");

aggregateComment.append(e.getMsg());

String revision = getRevision( e );
if (revision != null) {
aggregateComment.append(" (Revision ").append(revision).append(")");
}

aggregateComment.append("\n");
}
}

Expand All @@ -146,7 +150,8 @@ static void submitComments(
// 'issue doesn't exist'.
// To prevent carrying forward invalid issues forever, we have to drop them
// even if the cause of the exception was different.
logger.println("Looks like " + issue.id + " is no valid JIRA issue. Issue will not be updated or you dont have valid rights.\n" + e);
logger.println("Looks like " + issue.id + " is no valid JIRA issue or you don't have permission to update the issue.\n" +
"Issue will not be updated.\n" + e);
issues.remove(issue);
}
}
Expand Down Expand Up @@ -254,7 +259,13 @@ private static List<String> getScmComments(boolean wikiStyle, AbstractBuild<?, ?
}

private static String getRevision(Entry entry) {
// svn at least can get the revision
String commitId = entry.getCommitId();
if (commitId != null) {
return commitId;
}

// fall back to old SVN-specific solution, if we have only installed an old subversion-plugin
// which doesn't implement getCommitId, yet
try {
Class<?> clazz = entry.getClass();
Method method = clazz.getMethod( "getRevision", (Class[])null );
Expand Down

0 comments on commit 48c55e5

Please sign in to comment.