Skip to content
Permalink
Browse files

[FIXED JENKINS-14350] Adds branch information to the change set log

In the ChangeSetList screen (${BUILD_URL}/changes), if a branch was
discovered in the SCM changelog, display the branch name in the changeset
detail.
  • Loading branch information
Joe Hansche
Joe Hansche committed Jul 8, 2012
1 parent 3b1ad20 commit 305eb619fbe9d0229c54267473409907637e5ecf
@@ -32,6 +32,8 @@
private static final String PREFIX_AUTHOR = "author ";
private static final String PREFIX_COMMITTER = "committer ";
private static final String IDENTITY = "(.*)<(.*)> (.*) (.*)";
private static final String PREFIX_BRANCH = "Changes in branch ";
private static final String BRANCH_PATTERN = "([-_a-zA-Z0-9/]*),";


private static final Pattern FILE_LOG_ENTRY = Pattern.compile("^:[0-9]{6} [0-9]{6} ([0-9a-f]{40}) ([0-9a-f]{40}) ([ACDMRTUX])(?>[0-9]+)?\t(.*)$");
@@ -40,8 +42,11 @@
private static final Pattern COMMITTER_ENTRY = Pattern.compile("^"
+ PREFIX_COMMITTER + IDENTITY + "$");
private static final Pattern RENAME_SPLIT = Pattern.compile("^(.*?)\t(.*)$");
private static final Pattern BRANCH_ENTRY = Pattern.compile("^"
+ PREFIX_BRANCH + BRANCH_PATTERN + " .*$");

private static final String NULL_HASH = "0000000000000000000000000000000000000000";
private String branch;
private String committer;
private String committerEmail;
private String committerTime;
@@ -82,6 +87,12 @@ private void parseCommit(List<String> lines) {
} else if (line.startsWith("tree ")) {
} else if (line.startsWith("parent ")) {
this.parentCommit = line.split(" ")[1];
} else if (line.startsWith(PREFIX_BRANCH)) {
Matcher branchMatcher = BRANCH_ENTRY.matcher(line);
if (branchMatcher.matches()
&& branchMatcher.groupCount() >= 1) {
this.branch = branchMatcher.group(1).trim();
}
} else if (line.startsWith(PREFIX_COMMITTER)) {
Matcher committerMatcher = COMMITTER_ENTRY.matcher(line);
if (committerMatcher.matches()
@@ -312,6 +323,10 @@ public String getCommentAnnotated() {
return markup.toString(false);
}

public String getBranch() {
return this.branch;
}

@ExportedBean(defaultVisibility=999)
public static class Path implements AffectedFile {

@@ -27,6 +27,9 @@
</j:if>
by <a href="${rootURL}/${cs.author.url}/">${cs.author}</a>
</b>
<j:if test="${cs.branch!=null}">
<j:whitespace trim="false"> in ${cs.branch}</j:whitespace>
</j:if>
<pre>${cs.commentAnnotated}</pre>
</div>
</td>
@@ -46,4 +49,4 @@
</j:forEach>
</j:forEach>
</table>
</j:jelly>
</j:jelly>

0 comments on commit 305eb61

Please sign in to comment.
You can’t perform that action at this time.