Skip to content

Commit

Permalink
Merge pull request #50 from recena/case-sensitive
Browse files Browse the repository at this point in the history
[JENKINS-34410] Improved the search procedure of through SCMSourceCriteria
  • Loading branch information
recena committed Apr 27, 2016
2 parents 93b6b9e + 7f3c4b6 commit a10e869
Showing 1 changed file with 20 additions and 6 deletions.
Expand Up @@ -51,6 +51,7 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.github.GHBranch;
import org.kohsuke.github.GHContent;
import org.kohsuke.github.GHIssueState;
import org.kohsuke.github.GHMyself;
import org.kohsuke.github.GHOrganization;
Expand Down Expand Up @@ -340,13 +341,26 @@ protected SCMSourceCriteria.Probe getProbe(final String branch, final String thi
}
@Override public boolean exists(@Nonnull String path) throws IOException {
try {
repo.getFileContent(path, ref);
listener.getLogger().format(" %s exists in this %s%n", path, thing);
return true;
} catch (FileNotFoundException x) {
listener.getLogger().format(" %s does not exist in this %s%n", path, thing);
return false;
int index = path.lastIndexOf('/') + 1;
List<GHContent> directoryContent = repo.getDirectoryContent(path.substring(0, index), ref);
for (GHContent content : directoryContent) {
if (content.isFile()) {
String filename = path.substring(index);
if (content.getName().equals(filename)) {
listener.getLogger().format(" ‘%s’ exists in this %s%n", path, thing);
return true;
}
if (content.getName().equalsIgnoreCase(filename)) {
listener.getLogger().format(" ‘%s’ not found (but found ‘%s’, search is case sensitive) in this %s, skipping%n", path, content.getName(), thing);
return false;
}
}
}
} catch (FileNotFoundException fnf) {
// means that does not exist and this is handled below this try/catch block.
}
listener.getLogger().format(" ‘%s’ does not exist in this %s%n", path, thing);
return false;
}
};
}
Expand Down

0 comments on commit a10e869

Please sign in to comment.