提交 16e619b9 编写于 作者: K kohsuke

display tags that were already created.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3408 71c3de6d-444a-0410-be80-ed276b4c234a
上级 e41cbcdd
......@@ -22,6 +22,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.Map.Entry;
......@@ -35,17 +37,16 @@ import java.lang.ref.WeakReference;
public class SubversionTagAction extends AbstractScmTagAction {
/**
* If non-null, that means the build is already tagged.
* Map is from the repository URL to the URL of the tag.
* If a module is not tagged, the value will be null.
* Map is from the repository URL to the URLs of tags.
* If a module is not tagged, the value will be empty set.
*/
private final Map<SvnInfo,String> tags = new CopyOnWriteMap.Tree<SvnInfo,String>();
private final Map<SvnInfo,List<String>> tags = new CopyOnWriteMap.Tree<SvnInfo, List<String>>();
/*package*/ SubversionTagAction(AbstractBuild build,Collection<SvnInfo> svnInfos) {
super(build);
Map<SvnInfo,String> m = new HashMap<SvnInfo, String>();
Map<SvnInfo,List<String>> m = new HashMap<SvnInfo,List<String>>();
for (SvnInfo si : svnInfos)
m.put(si,null);
m.put(si,new ArrayList<String>());
tags.putAll(m);
}
......@@ -57,8 +58,8 @@ public class SubversionTagAction extends AbstractScmTagAction {
public String getDisplayName() {
int nonNullTag = 0;
for (String v : tags.values()) {
if(v!=null) {
for (List<String> v : tags.values()) {
if(!v.isEmpty()) {
nonNullTag++;
if(nonNullTag>1)
break;
......@@ -75,10 +76,20 @@ public class SubversionTagAction extends AbstractScmTagAction {
/**
* @see #tags
*/
public Map<SvnInfo,String> getTags() {
public Map<SvnInfo,List<String>> getTags() {
return Collections.unmodifiableMap(tags);
}
/**
* Returns true if this build has already been tagged at least once.
*/
public boolean isTagged() {
for (List<String> t : tags.values()) {
if(!t.isEmpty()) return true;
}
return false;
}
private static final Pattern TRUNK_BRANCH_MARKER = Pattern.compile("/(trunk|branches)(/|$)");
/**
......@@ -106,11 +117,11 @@ public class SubversionTagAction extends AbstractScmTagAction {
Map<SvnInfo,String> newTags = new HashMap<SvnInfo,String>();
int i=-1;
for (Entry<SvnInfo, String> e : tags.entrySet()) {
for (SvnInfo e : tags.keySet()) {
i++;
if(tags.size()>1 && req.getParameter("tag"+i)==null)
continue; // when tags.size()==1, UI won't show the checkbox.
newTags.put(e.getKey(),req.getParameter("name" + i));
newTags.put(e,req.getParameter("name" + i));
}
new TagWorkerThread(newTags).start();
......@@ -156,8 +167,10 @@ public class SubversionTagAction extends AbstractScmTagAction {
}
// completed successfully
SubversionTagAction.this.tags.putAll(tagSet);
for (Entry<SvnInfo,String> e : tagSet.entrySet())
SubversionTagAction.this.tags.get(e.getKey()).add(e.getValue());
build.save();
workerThread = null;
} catch (Throwable e) {
e.printStackTrace(listener.fatalError(e.getMessage()));
}
......
......@@ -4,12 +4,44 @@
This belongs to a build view.
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout norefresh="true">
<d:taglib uri="local">
<d:tag name="listTags">
<ul>
<j:forEach var="t" items="${tags}">
<li>${t}</li>
</j:forEach>
</ul>
</d:tag>
</d:taglib>
<l:layout norefresh="true" xmlns:local="local">
<st:include it="${it.build}" page="sidepanel.jelly" />
<l:main-panel>
<h1>Build #${it.build.number}</h1>
<j:set var="tags" value="${it.tags}" />
<j:if test="${it.isTagged()}">
<p>
This build is already tagged:
</p>
<j:choose>
<j:when test="${tags.size()==1}">
<local:listTags tags="${tags.values().iterator().next()}"/>
</j:when>
<j:otherwise>
<ul>
<j:forEach var="m" items="${tags.entrySet}">
<li>
${m.key.url}
<local:listTags tags="${m.value}"/>
</li>
</j:forEach>
</ul>
</j:otherwise>
</j:choose>
<h2>Create more tags</h2>
</j:if>
<form action="submit" method="get">
<table class="middle-align">
<tr>
......@@ -19,17 +51,17 @@
<th>Module URL</th>
<th>Tag URL</th>
</tr>
<j:forEach var="m" items="${tags.entrySet()}" varStatus="loop">
<j:forEach var="m" items="${tags.keySet()}" varStatus="loop">
<tr>
<j:if test="${tags.size()!=1}">
<td><input type="checkbox" name="tag${loop.index}" checked="true" id="tag${loop.index}" onchange="updateRow(this,${loop.index})" /></td>
</j:if>
<td style="white-space:nowrap;"><label for="tag${loop.index}">
${m.key.url} (rev.${m.key.revision})
${m.url} (rev.${m.revision})
</label></td>
<td width="100%">
<input type="text" name="name${loop.index}"
value="${it.makeTagURL(m.key)}" style="width:100%" id="name${loop.index}" />
value="${it.makeTagURL(m)}" style="width:100%" id="name${loop.index}" />
</td>
</tr>
</j:forEach>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册