in javatests/com/google/gitiles/TestGitilesAccess.java [38:90]
public GitilesAccess forRequest(final HttpServletRequest req) {
return new GitilesAccess() {
@Override
public Map<String, RepositoryDescription> listRepositories(
String prefix, Set<String> branches) {
String name = repo.getDescription().getRepositoryName();
if (prefix != null) {
String pattern = CharMatcher.is('/').trimFrom(prefix) + '/';
if (!name.startsWith(pattern)) {
return Collections.emptyMap();
}
}
if (branches != null && !branches.isEmpty()) {
throw new UnsupportedOperationException("branches set not yet supported");
}
RepositoryDescription desc = new RepositoryDescription();
desc.name = name;
desc.cloneUrl = TestGitilesUrls.URLS.getBaseGitUrl(req) + "/" + desc.name;
return ImmutableMap.of(desc.name, desc);
}
@Override
public Object getUserKey() {
return "a user";
}
@Override
public String getRepositoryName() {
return repo.getDescription().getRepositoryName();
}
@Override
public RepositoryDescription getRepositoryDescription() {
RepositoryDescription d = new RepositoryDescription();
d.name = getRepositoryName();
d.description = "a test data set";
d.cloneUrl = TestGitilesUrls.URLS.getBaseGitUrl(req) + "/" + d.name;
return d;
}
@Override
public Config getConfig() {
Config config = new Config();
config.setBoolean("markdown", null, "blocknote", true);
config.setBoolean("markdown", null, "multicolumn", true);
config.setBoolean("markdown", null, "namedanchor", true);
config.setBoolean("markdown", null, "smartquote", true);
config.setStringList(
"gitiles", null, "allowOriginRegex", ImmutableList.of("http://localhost"));
return config;
}
};
}