Skip to content

Commit

Permalink
Merge pull request #73 from cbos/master
Browse files Browse the repository at this point in the history
Fix JENKINS-22199
  • Loading branch information
ndeloof committed Mar 31, 2014
2 parents ed6e43e + fe0b641 commit 0a17b93
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/main/java/hudson/scm/DirAwareSVNXMLLogHandler.java
Expand Up @@ -87,7 +87,10 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
Map<String, SVNLogEntryPath> changedPaths = new HashMap<String, SVNLogEntryPath>();
for (SVNLogEntryPath entry : logEntry.getChangedPaths().values()) {
String localPath = entry.getPath().substring(1); // path in svn log start with a '/'
localPath = relativePath + localPath.substring(relativeUrl.length());
if(localPath.startsWith(relativeUrl))
{
localPath = relativePath + localPath.substring(relativeUrl.length());
}
// can't use entry.setPath(localPath) as FSPathChange duplicate myPath attribute then setPath().getPath() don't return same value
changedPaths.put(localPath, new SVNLogEntryPath(localPath, entry.getType(), entry.getCopyPath(), entry.getCopyRevision()));
}
Expand Down
22 changes: 18 additions & 4 deletions src/test/java/hudson/scm/SubversionSCMTest.java
Expand Up @@ -33,6 +33,7 @@
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.cloudbees.plugins.credentials.domains.Domain;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;

import hudson.FilePath;
import hudson.Launcher;
import hudson.Proc;
Expand Down Expand Up @@ -81,6 +82,8 @@

import org.dom4j.Document;
import org.dom4j.io.DOMReader;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.Email;
Expand Down Expand Up @@ -119,6 +122,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

import hudson.EnvVars;
import hudson.model.EnvironmentContributor;

Expand Down Expand Up @@ -1096,7 +1100,8 @@ public void testExternalsAffectedPaths() throws Exception {
forCommit.setAssignedLabel(hudson.getSelfLabel());
// Build once to get a working copy in job workspace
FreeStyleBuild b = assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get());
FilePath foo = b.getWorkspace().child("foo");
String folderName = "foo1234567890foo1234567890"; //long path to check substring action
FilePath foo = b.getWorkspace().child(folderName);
foo.mkdirs();
FilePath newFile = foo.child("README.txt");
newFile.touch(System.currentTimeMillis());
Expand All @@ -1116,7 +1121,7 @@ public void testExternalsAffectedPaths() throws Exception {
// setup foo directory in ext as svn:externals on "ext",
FreeStyleBuild bb = assertBuildStatusSuccess(p.scheduleBuild2(0).get());
String externalURL = "file://" + ext.toURI().toURL().getPath();
SVNPropertyValue externals = SVNPropertyValue.create("ext " + externalURL + "/foo");
SVNPropertyValue externals = SVNPropertyValue.create("ext " + externalURL + "/" + folderName);
SvnClientManager svnm2 = SubversionSCM.createClientManager(forCommit);
svnm2.getWCClient().doSetProperty(new File(bb.getWorkspace().getRemote()), "svn:externals", externals, true, SVNDepth.FILES, null, null);
svnm2.getCommitClient().doCommit(new File[]{new File(bb.getWorkspace().getRemote())},false,"externals",null,null,false,false,SVNDepth.INFINITY);
Expand All @@ -1130,15 +1135,24 @@ public void testExternalsAffectedPaths() throws Exception {
newFile = foo.child("something.txt");
newFile.touch(System.currentTimeMillis());
svnm.getWCClient().doAdd(new File(newFile.getRemote()), false, false, false, SVNDepth.INFINITY, false, false);
cc.doCommit(new File[]{new File(newFile.getRemote())},false,"added",null,null,false,false,SVNDepth.INFINITY);
// create another folder with content outside the ext folder
FilePath anotherDir = foo.getParent().child("anotherDir");
anotherDir.mkdirs();
FilePath anotherFile = anotherDir.child("a.txt");
anotherFile.touch(System.currentTimeMillis());
svnm.getWCClient().doAdd(new File(anotherDir.getRemote()),false,false,false, SVNDepth.INFINITY, false,false);

cc.doCommit(new File[]{new File(newFile.getRemote()), new File(anotherDir.getRemote())},false,"added",null,null,false,false,SVNDepth.INFINITY);

FreeStyleBuild build = p.scheduleBuild2(2).get();
assertBuildStatusSuccess(build);
Collection<String> paths = new ArrayList<String>();
for (ChangeLogSet.Entry e : build.getChangeSet()) {
for (String path : e.getAffectedPaths()) {
assertEquals("ext/something.txt", path);
paths.add(path);
}
}
Assert.assertThat(paths, Matchers.containsInAnyOrder("ext/something.txt", "anotherDir", "anotherDir/a.txt"));
}

public void testCompareSVNAuthentications() throws Exception {
Expand Down

1 comment on commit 0a17b93

@astellingwerf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there plans to release this fix any time soon? We're hit pretty badly by this issue.

Please sign in to comment.