Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#8 ability to configure ignore merge patterns

  • Loading branch information...
commit dc5699a0ed66354b0465f2292c6e5cea450ab649 1 parent d8a8f77
@vberetti vberetti authored
View
55 src/main/java/hudson/plugins/jigomerge/JigomergeBuilder.java
@@ -4,18 +4,19 @@
import groovy.lang.GroovyObject;
import hudson.Extension;
import hudson.Launcher;
+import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.model.BuildListener;
-import hudson.model.AbstractBuild;
import hudson.model.Descriptor;
import hudson.tasks.Builder;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
@@ -35,9 +36,12 @@
private boolean dryRun;
private boolean verbose;
private final String validationScript;
+ private final List<String> ignoreMergePatterns;
@DataBoundConstructor
- public JigomergeBuilder(String source, String username, String password, boolean oneByOne, boolean eager, String validationScript, boolean dryRun, boolean verbose) {
+ public JigomergeBuilder(String source, String username, String password,
+ boolean oneByOne, boolean eager, String validationScript,
+ boolean dryRun, boolean verbose, String ignoreMergePatterns) {
this.source = source;
this.username = username;
this.password = password;
@@ -45,11 +49,20 @@ public JigomergeBuilder(String source, String username, String password, boolean
this.eager = eager;
this.dryRun = dryRun;
this.verbose = verbose;
- if(StringUtils.isNotEmpty(validationScript)){
+
+ if (StringUtils.isNotEmpty(validationScript)) {
this.validationScript = validationScript;
- }else{
+ } else {
this.validationScript = null;
}
+
+ this.ignoreMergePatterns = new ArrayList<String>();
+ if (StringUtils.isNotEmpty(ignoreMergePatterns)) {
+ StringTokenizer tokenizer = new StringTokenizer(ignoreMergePatterns, ",");
+ while (tokenizer.hasMoreTokens()) {
+ this.ignoreMergePatterns.add(tokenizer.nextToken());
+ }
+ }
}
@Override
@@ -58,8 +71,9 @@ public JigomergeBuilder(String source, String username, String password, boolean
}
@Override
- public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher, final BuildListener listener)
- throws InterruptedException, IOException {
+ public boolean perform(final AbstractBuild<?, ?> build,
+ final Launcher launcher, final BuildListener listener)
+ throws InterruptedException, IOException {
String workingDirectory = build.getModuleRoot().toURI().getPath();
MergeResult result = new MergeResult();
@@ -67,20 +81,24 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,
try {
InputStream scriptResource = this.getClass().getResourceAsStream(
- "/scripts/jigomerge-" + JIGOMERGE_VERSION + ".groovy");
+ "/scripts/jigomerge-" + JIGOMERGE_VERSION + ".groovy");
GroovyClassLoader gcl = new GroovyClassLoader();
Class<?> clazz = gcl.parseClass(scriptResource);
Constructor<?>[] constructors = clazz.getConstructors();
- GroovyObject instance = (GroovyObject) constructors[0].newInstance(dryRun, Collections.EMPTY_LIST, oneByOne, eager,
- verbose, username, password, listener.getLogger());
-
- Object[] mergeArgs = { source, validationScript, workingDirectory + '.'};
- Map returnedObject = (Map) instance.invokeMethod("launchSvnMerge", mergeArgs);
+ GroovyObject instance = (GroovyObject) constructors[0].newInstance(
+ dryRun, ignoreMergePatterns, oneByOne, eager, verbose,
+ username, password, listener.getLogger());
+
+ Object[] mergeArgs = { source, validationScript,
+ workingDirectory + '.' };
+ Map returnedObject = (Map) instance.invokeMethod("launchSvnMerge",
+ mergeArgs);
listener.getLogger().println("return : " + returnedObject);
// fill merge result
result.setStatus((Boolean) returnedObject.get("status"));
- List<String> conflictingRevisions = (List<String>) returnedObject.get("conflictingRevisions");
+ List<String> conflictingRevisions = (List<String>) returnedObject
+ .get("conflictingRevisions");
if (conflictingRevisions != null) {
result.getConflictingRevisions().addAll(conflictingRevisions);
}
@@ -124,6 +142,11 @@ public boolean isVerbose() {
}
public String getValidationScript() {
- return validationScript;
- }
+ return validationScript;
+ }
+
+ public String getIgnoreMergePatterns() {
+ return StringUtils.join(ignoreMergePatterns.toArray(), ",");
+ }
+
}
View
3  src/main/resources/hudson/plugins/jigomerge/JigomergeBuilder/config.jelly
@@ -20,6 +20,9 @@
<f:entry title="eager mode" help="${rootURL}/plugin/jigomerge/help-builder-eager.html">
<f:checkbox field="eager" />
</f:entry>
+ <f:entry title="ignore merge patterns" help="${rootURL}/plugin/jigomerge/help-builder-ignoreMergePatterns.html">
+ <f:textbox field="ignoreMergePatterns" />
+ </f:entry>
<f:entry title="dry run" help="${rootURL}/plugin/jigomerge/help-builder-dryRun.html">
<f:checkbox field="dryRun" />
</f:entry>
View
5 src/main/webapp/help-builder-ignoreMergePatterns.html
@@ -0,0 +1,5 @@
+<div>
+ A list of patterns separated by a comma. If a commit comment contains on of this pattern, this commit will not be merged.<br>
+ Warning : string tokens are not trimed. The following "AA , BB", will try to match " AA" and "BB " but not "AA" and "BB"<br>
+ If no pattern is specified, the default list is used : maven-release-plugin,NOMERGE,NO-MERGE,NO MERGE,NO_MERGE
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.