提交 f00979ae 编写于 作者: M mindless

[FIXED HUDSON-1879] don't allow renaming a job while a build is running.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@18628 71c3de6d-444a-0410-be80-ed276b4c234a
上级 8c1e7a0e
......@@ -605,14 +605,6 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return Hudson.getInstance().getQueue().getItem(this);
}
/**
* Returns true if a build of this project is in progress.
*/
public boolean isBuilding() {
R b = getLastBuild();
return b!=null && b.isBuilding();
}
/**
* Gets the JDK that this project is configured with, or null.
*/
......
......@@ -210,6 +210,14 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return null;
}
/**
* Returns true if a build of this project is in progress.
*/
public boolean isBuilding() {
RunT b = getLastBuild();
return b!=null && b.isBuilding();
}
/**
* Get the term used in the UI to represent this kind of
* {@link AbstractProject}. Must start with a capital letter.
......@@ -1195,6 +1203,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return;
}
if (isBuilding()) {
// redirect to page explaining that we can't rename now
rsp.sendRedirect("rename?newName=" + newName);
return;
}
renameTo(newName);
// send to the new job page
// note we can't use getUrl() because that would pick up old name in the
......
......@@ -25,15 +25,25 @@ THE SOFTWARE.
<!-- Rename project -->
<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" xmlns:i="jelly:fmt">
<l:layout>
<st:include page="sidepanel.jelly" />
<l:main-panel>
<j:set var="newName" value="${request.getParameter('newName')}" />
<form method="get" action="doRename">
${%description(it.name, newName)}
<input type="hidden" name="newName" value="${newName}" />
<f:submit value="${%Yes}" />
<input type="button" value="${%No}" onclick="javascript:history.back()" class="yui-button" />
</form>
<st:include page="sidepanel.jelly" />
<l:main-panel>
<j:choose>
<j:when test="${it.isBuilding()}">
${%noRenameWhileBuilding}
<j:if test="${request.referer.endsWith('/configure')}">
<br/> ${%configWasSaved}
</j:if>
</j:when>
<j:otherwise>
<j:set var="newName" value="${request.getParameter('newName')}" />
<form method="get" action="doRename">
${%description(it.name, newName)}
<input type="hidden" name="newName" value="${newName}" />
<f:submit value="${%Yes}" />
<input type="button" value="${%No}" onclick="javascript:history.back()" class="yui-button" />
</form>
</j:otherwise>
</j:choose>
</l:main-panel>
</l:layout>
</j:jelly>
\ No newline at end of file
</j:jelly>
......@@ -20,6 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
noRenameWhileBuilding=Unable to rename a job while it is building.
configWasSaved=All other configuration options were saved.
description=Are you sure about renaming {0} to {1}?
Yes=Yes
No=No
\ No newline at end of file
No=No
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册