Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-12948] adding form validation for -p and -f option con…
…flict
  • Loading branch information
Rob Petti committed Mar 7, 2012
1 parent 78f498f commit eeae9a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -1839,6 +1839,17 @@ public FormValidation doValidateExcludedFiles(StaplerRequest req) {
return FormValidation.ok();
}

public FormValidation doValidateForceSync(StaplerRequest req) {
Boolean forceSync = Boolean.valueOf(fixNull(req.getParameter("forceSync")).trim());
Boolean alwaysForceSync = Boolean.valueOf(fixNull(req.getParameter("alwaysForceSync")).trim());
Boolean dontUpdateServer = Boolean.valueOf(fixNull(req.getParameter("dontUpdateServer")).trim());

if((forceSync || alwaysForceSync) && dontUpdateServer){
return FormValidation.error("Don't Update Server Database (-p) option is incompatible with force syncing! Either disable -p, or disable force syncing.");
}
return FormValidation.ok();
}

public List<String> getAllLineEndChoices(){
List<String> allChoices = Arrays.asList(
"local",
Expand Down
Expand Up @@ -97,11 +97,11 @@
</f:entry>

<f:entry title="One Time Force Sync" help="/plugin/perforce/help/forceSync.html">
<f:checkbox field="forceSync" value="True"/>
<f:checkbox field="forceSync" value="True" id="forceSync" onchange="this.form.elements['dontUpdateServer'].changed();"/>
</f:entry>

<f:entry title="Always Force Sync" help="/plugin/perforce/help/alwaysForceSync.html">
<f:checkbox field="alwaysForceSync" value="True"/>
<f:checkbox field="alwaysForceSync" value="True" id="alwaysForceSync" />
</f:entry>

<f:entry title="Disable Sync and Changelog" help="/plugin/perforce/help/disableAutoSync.html">
Expand Down Expand Up @@ -147,7 +147,8 @@
<f:checkbox field="dontUpdateClient" default="false" />
</f:entry>
<f:entry title="Don't update server database on sync (-p)" help="/plugin/perforce/help/dontUpdateServer.html">
<f:checkbox field="dontUpdateServer" default="false" />
<f:checkbox field="dontUpdateServer" default="false" id="dontUpdateServer"
checkUrl="'${rootURL}/scm/PerforceSCM/validateForceSync?dontUpdateServer='+escape(this.form.elements['dontUpdateServer'].checked)+'&amp;forceSync='+escape(this.form.elements['forceSync'].checked)+'&amp;alwaysForceSync='+escape(this.form.elements['alwaysForceSync'].checked)"/>
</f:entry>
<f:entry title="Client name format for slaves" help="/plugin/perforce/help/clientNameFormat.html">
<f:textbox field="slaveClientNameFormat"/>
Expand Down Expand Up @@ -200,5 +201,9 @@
</f:advanced>

<t:listScmBrowsers name="browser" />
<script language="javascript">
this.document.getElementById('alwaysForceSync').onchange= function () {this.form.elements["dontUpdateServer"].onchange();};
this.document.getElementById('forceSync').onchange= function () {this.form.elements["dontUpdateServer"].onchange();};
</script>

</j:jelly>

0 comments on commit eeae9a5

Please sign in to comment.