Skip to content
Permalink
Browse files

[JENKINS-41626] Fix path detection when subfolder older than root fol…

…der (#205)

* Fix for JENKINS-41626

Checks for folders in HEAD, then checks if the candidate folder is available using it's revision, if not report it as the HEAD revision.

* Clean up parameter that no longer matters
  • Loading branch information...
Andne authored and oleg-nenashev committed Mar 4, 2018
1 parent c056e9a commit 82e77a01979798ede7ca5f22dceaca03c6d2a737
Showing with 12 additions and 9 deletions.
  1. +12 −9 src/main/java/jenkins/scm/impl/subversion/SubversionSCMSource.java
@@ -243,7 +243,6 @@ protected void retrieve(@CheckForNull SCMSourceCriteria criteria,
List<String> prefix = Collections.emptyList();
fetch(listener,
repository,
-1,
repoPath,
toPaths(splitCludes(includes)),
prefix,
@@ -343,7 +342,6 @@ private SVNRepositoryView openSession(SVNURL repoURL) throws SVNException, IOExc

void fetch(@NonNull TaskListener listener,
@NonNull final SVNRepositoryView repository,
long rev,
@NonNull final String repoPath,
@NonNull SortedSet<List<String>> paths,
@NonNull List<String> prefix,
@@ -356,8 +354,8 @@ void fetch(@NonNull TaskListener listener,
assert prefix.size() == realPath.size();
assert wildcardStartsWith(realPath, prefix);
SortedMap<List<String>, SortedSet<List<String>>> includePaths = groupPaths(paths, prefix);
listener.getLogger().println("Checking directory " + svnPath + (rev > -1 ? "@" + rev : "@HEAD"));
SVNRepositoryView.NodeEntry node = repository.getNode(svnPath, rev);
listener.getLogger().println("Checking directory " + svnPath + "@HEAD");
SVNRepositoryView.NodeEntry node = repository.getNode(svnPath, -1);
if (!SVNNodeKind.DIR.equals(node.getType()) || node.getChildren() == null) {
return;
}
@@ -384,7 +382,7 @@ public int compare(SVNRepositoryView.ChildEntry o1, SVNRepositoryView.ChildEntry
final long candidateRevision = svnEntry.getRevision();
final long lastModified = svnEntry.getLastModified();
listener.getLogger().println(
"Checking candidate branch " + candidateRootPath + "@" + candidateRevision);
"Checking candidate branch " + candidateRootPath + "@HEAD");
if (branchCriteria == null || branchCriteria.isHead(
new SCMSourceCriteria.Probe() {
@Override
@@ -402,24 +400,29 @@ public boolean exists(@NonNull String path) throws IOException {
try {
return repository.checkPath(
SVNPathUtil.append(candidateRootPath, path),
candidateRevision) != SVNNodeKind.NONE;
-1) != SVNNodeKind.NONE;
} catch (SVNException e) {
throw new IOException(e);
}
}
}, listener)) {
listener.getLogger().println("Met criteria");
long branchRevision = candidateRevision;
if (repository.checkPath(candidateRootPath, branchRevision) == SVNNodeKind.NONE)
{
listener.getLogger().println("Branch older than root folder, using HEAD");
branchRevision = -1;
}
SCMHead head = new SCMHead(childPath);
observer.observe(head, new SCMRevisionImpl(head, svnEntry.getRevision()));
observer.observe(head, new SCMRevisionImpl(head, branchRevision));
if (!observer.isObserving()) {
return;
}
} else {
listener.getLogger().println("Does not meet criteria");
}
} else {
fetch(listener, repository, svnEntry.getRevision(), repoPath, paths,
childPrefix,
fetch(listener, repository, repoPath, paths, childPrefix,
childRealPath, excludedPaths, branchCriteria, observer);
}
}

0 comments on commit 82e77a0

Please sign in to comment.
You can’t perform that action at this time.