Skip to content

Commit

Permalink
Merge pull request #14 from hugueschabot/jenkins-23371
Browse files Browse the repository at this point in the history
[FIXED JENKINS-23371] Ignore svn:externals when reintegrating branch
  • Loading branch information
hugueschabot committed Jul 15, 2014
2 parents 5880b5a + af075af commit 990dc84
Showing 1 changed file with 46 additions and 5 deletions.
51 changes: 46 additions & 5 deletions src/main/java/jenkins/plugins/svnmerge/IntegrateAction.java
Expand Up @@ -9,21 +9,25 @@
import hudson.model.Queue.Task;
import hudson.model.TaskListener;
import hudson.scm.ChangeLogSet.Entry;
import hudson.scm.SCM;
import hudson.scm.SubversionChangeLogSet.LogEntry;
import hudson.scm.SubversionSCM;
import hudson.scm.SubversionSCM.ModuleLocation;
import hudson.scm.SubversionSCM.SvnInfo;
import hudson.scm.SubversionTagAction;
import hudson.security.ACL;
import jenkins.model.Jenkins;
import jenkins.plugins.svnmerge.FeatureBranchProperty.IntegrationResult;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.tmatesoft.svn.core.SVNException;

import javax.servlet.ServletException;
import java.io.File;
import java.io.IOException;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* {@link AbstractBuild}-level action to integrate
Expand Down Expand Up @@ -115,10 +119,47 @@ protected IntegrateSetting createParams(StaplerRequest req) throws IOException {
*/
public SvnInfo getSvnInfo() {
SubversionTagAction sta = build.getAction(SubversionTagAction.class);
if(sta==null) return null;
Map<SvnInfo,List<String>> tags = sta.getTags();
if(tags.size()!=1) return null; // can't handle more than 1 URLs
return tags.keySet().iterator().next();

if (sta == null) {
return null;
}

Set<SvnInfo> svnInfos = sta.getTags().keySet();

if (svnInfos.isEmpty()) {
return null;
} else if (svnInfos.size() == 1) {
return svnInfos.iterator().next();
} else {
// Assume the the project SVN module has externals.

SCM scm = getProject().getScm();
if (!(scm instanceof SubversionSCM)) {
return null;
}

//TODO: check for multiple locations ?
SubversionSCM svn = (SubversionSCM) scm;
ModuleLocation[] locations = svn.getLocations();

if (locations.length == 1) {
ModuleLocation firstLocation = svn.getLocations()[0];

if (!firstLocation.isIgnoreExternalsOption()) {
for (SvnInfo svnInfo : svnInfos) {
try {
if (svnInfo.getSVNURL().equals(firstLocation.getSVNURL())) {
return svnInfo;
}
} catch (SVNException e) {
// Ignore
}
}
}
}

return null; // can't handle more than 1 URLs
}
}

/**
Expand Down

0 comments on commit 990dc84

Please sign in to comment.