Skip to content

Commit

Permalink
[JENKINS-41626] Fix path detection when subfolder older than root fol…
Browse files Browse the repository at this point in the history
…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 82e77a0
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/main/java/jenkins/scm/impl/subversion/SubversionSCMSource.java
Expand Up @@ -243,7 +243,6 @@ protected void retrieve(@CheckForNull SCMSourceCriteria criteria,
List<String> prefix = Collections.emptyList();
fetch(listener,
repository,
-1,
repoPath,
toPaths(splitCludes(includes)),
prefix,
Expand Down Expand Up @@ -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,
Expand All @@ -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;
}
Expand All @@ -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
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 82e77a0

Please sign in to comment.