Skip to content

Commit

Permalink
[FIXED JENKINS-9914] Using proper databinding scheme and adding help …
Browse files Browse the repository at this point in the history
…for these fields.
  • Loading branch information
kohsuke committed Aug 19, 2011
1 parent 5d6aa56 commit e4dcece
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/git/BranchSpec.java
Expand Up @@ -10,7 +10,7 @@

/**
* A specification of branches to build. Rather like a refspec.
*
*
* eg:
* master
* origin/master
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/hudson/plugins/git/GitPublisher.java
Expand Up @@ -201,8 +201,7 @@ gitExe, new FilePath(workspace),

PreBuildMergeOptions mergeOptions = gitSCM.getMergeOptions();

if (mergeOptions.doMerge() && buildResult.isBetterOrEqualTo(
Result.SUCCESS)) {
if (mergeOptions.doMerge() && buildResult.isBetterOrEqualTo(Result.SUCCESS)) {
RemoteConfig remote = mergeOptions.getMergeRemote();
listener.getLogger().println("Pushing result " + buildnumber + " to " + mergeOptions.getMergeTarget() + " branch of " + remote.getName() + " repository");

Expand Down
8 changes: 6 additions & 2 deletions src/main/java/hudson/plugins/git/GitSCM.java
Expand Up @@ -175,7 +175,7 @@ public GitSCM(
String scmName,
List<UserRemoteConfig> userRemoteConfigs,
List<BranchSpec> branches,
UserMergeOptions doMerge,
UserMergeOptions userMergeOptions,
Boolean doGenerateSubmoduleConfigurations,
Collection<SubmoduleConfig> submoduleCfg,
boolean clean,
Expand Down Expand Up @@ -208,7 +208,7 @@ public GitSCM(
this.localBranch = Util.fixEmptyAndTrim(localBranch);

this.userRemoteConfigs = userRemoteConfigs;
this.userMergeOptions = doMerge;
this.userMergeOptions = userMergeOptions;
updateFromUserData();

// TODO: getBrowserFromRequest
Expand Down Expand Up @@ -1603,6 +1603,10 @@ public PreBuildMergeOptions getMergeOptions() {
return mergeOptions;
}

public UserMergeOptions getUserMergeOptions() {
return userMergeOptions;
}

/**
* Look back as far as needed to find a valid BuildData. BuildData
* may not be recorded if an exception occurs in the plugin logic.
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/hudson/plugins/git/UserMergeOptions.java
@@ -1,9 +1,15 @@
package hudson.plugins.git;

import java.io.Serializable;

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.util.FormValidation;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

public class UserMergeOptions implements Serializable {
public class UserMergeOptions extends AbstractDescribableImpl<UserMergeOptions> implements Serializable {

private String mergeRemote;
private String mergeTarget;
Expand All @@ -21,4 +27,12 @@ public String getMergeRemote() {
public String getMergeTarget() {
return mergeTarget;
}

@Extension
public static class DescriptorImpl extends Descriptor<UserMergeOptions> {
@Override
public String getDisplayName() {
return "";
}
}
}
33 changes: 9 additions & 24 deletions src/main/resources/hudson/plugins/git/GitSCM/config.jelly
Expand Up @@ -115,31 +115,16 @@
</f:entry>
-->

<f:entry title="Merge options" help="/plugin/git/merge.html">

<table width="100%">
<f:optionalBlock field="doMerge"
title="${%Merge before build}"
checked="${scm.mergeOptions.doMerge()}">
<f:entry title="Name of repository: (default first specified, e.g. origin)" field="mergeRemote">
<f:textbox id="git.mergeRemote" value="${scm.mergeOptions.getMergeRemote().getName()}"/>
<!-- TODO add the check url. Note that we cannot rely on the repo.name tag to be at the root of the form -->
<!-- checkUrl="'${rootURL}/scm/GitSCM/gitRemoteNameCheck?isMerge=true&amp;value='+escape(this.value)
+encodeAllInputs('&amp;', this.form, 'repo.name')
+encodeAllInputs('&amp;', this.form, 'repo.url')"/ -->
</f:entry>
<f:entry title="Branch to merge to: (e.g. master)" field="mergeTarget">
<f:textbox id="git.mergeTarget" value="${scm.mergeOptions.getMergeTarget()}" clazz="required"/>
</f:entry>
</f:optionalBlock>
</table>

</f:entry>

<f:entry title="Prune remote branches before build" field="pruneBranches" help="/plugin/git/prune.html">
<f:checkbox />
</f:entry>
<f:entry title="Merge options">
<table width="100%">
<f:optionalProperty title="${%Merge before build}" field="userMergeOptions" />
</table>
</f:entry>

<f:entry title="Prune remote branches before build" field="pruneBranches" help="/plugin/git/prune.html">
<f:checkbox/>
</f:entry>

<f:entry title="Skip internal tag" field="skipTag" help="/plugin/git/help-skipTag.html">
<f:checkbox />
Expand Down
File renamed without changes.
@@ -0,0 +1,12 @@
<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">
<f:entry title="Name of repository" field="mergeRemote">
<f:textbox id="git.mergeRemote" />
<!-- TODO add the check url. Note that we cannot rely on the repo.name tag to be at the root of the form -->
<!-- checkUrl="'${rootURL}/scm/GitSCM/gitRemoteNameCheck?isMerge=true&amp;value='+escape(this.value)
+encodeAllInputs('&amp;', this.form, 'repo.name')
+encodeAllInputs('&amp;', this.form, 'repo.url')"/ -->
</f:entry>
<f:entry title="${%Branch to merge to}" field="mergeTarget">
<f:textbox id="git.mergeTarget" clazz="required"/>
</f:entry>
</j:jelly>
@@ -0,0 +1,4 @@
<div>
Name of the repository, such as <tt>origin</tt>, that contains the branch you specify below. If left blank,
it'll default to the name of the first repository configured above.
</div>
@@ -0,0 +1,3 @@
<div>
The name of the branch within the named repository to merge to, such as <tt>master</tt>.
</div>
3 changes: 2 additions & 1 deletion src/main/webapp/branch.html
@@ -1,3 +1,4 @@
<div>
Specify the branch name if you'd like to track a specific branch in a repository. If left blank, all branches will be examined for changes and built.
Specify the branches if you'd like to track a specific branch in a repository. If left blank, all branches will be examined for changes and built.
The syntax is <tt>REPOSITORYNAME/</tt>
</div>

0 comments on commit e4dcece

Please sign in to comment.