Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
Upgrade bazlets to latest stable-2.15 to build with 2.15.16 API
Upgrade bazlets to latest stable-2.15 to build with 2.15.15 API
Change-Id: I6e084f37abc6fd7efe6c9f8463096fca85f384a1
diff --git a/BUILD b/BUILD
index 7f19fc3..fd1450c 100644
--- a/BUILD
+++ b/BUILD
@@ -39,6 +39,7 @@
"@cm-autolink//jar",
"@commonmark//jar",
"@commons-lang3//jar",
+ "@commons-text//jar",
"@gfm-strikethrough//jar",
"@gfm-tables//jar",
"@gitiles-servlet//jar",
diff --git a/WORKSPACE b/WORKSPACE
index f75f37c..aee0921 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "4b3ce19d8d18d9f7df56a06532723b91ea6949d0",
+ commit = "5514e42e08d7852d226849e391857d7f139f7ed9",
#local_path = "/home/<user>/projects/bazlets",
)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
index 85c3a37..5f4313d 100644
--- a/external_plugin_deps.bzl
+++ b/external_plugin_deps.bzl
@@ -5,8 +5,8 @@
def external_plugin_deps():
maven_jar(
name = "gitiles-servlet",
- artifact = "com.google.gitiles:gitiles-servlet:0.2-5",
- sha1 = "18186bd83a8c52a4a965472fcb9b4ea87862eb35",
+ artifact = "com.google.gitiles:gitiles-servlet:0.2-7",
+ sha1 = "f23b22cb27fe5c4a78f761492082159d17873f57",
repository = GERRIT,
)
@@ -23,6 +23,12 @@
sha1 = "557edd918fd41f9260963583ebf5a61a43a6b423",
)
+ maven_jar(
+ name = "commons-text",
+ artifact = "org.apache.commons:commons-text:1.2",
+ sha1 = "74acdec7237f576c4803fff0c1008ab8a3808b2b",
+ )
+
# commonmark must match the version used in Gitiles
maven_jar(
name = "commonmark",
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitiles/FilteredRepository.java b/src/main/java/com/googlesource/gerrit/plugins/gitiles/FilteredRepository.java
index 039f78f..3dee013 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitiles/FilteredRepository.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitiles/FilteredRepository.java
@@ -21,8 +21,8 @@
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.git.GitRepositoryManager;
-import com.google.gerrit.server.git.VisibleRefFilter;
import com.google.gerrit.server.permissions.PermissionBackend;
+import com.google.gerrit.server.permissions.PermissionBackend.RefFilterOptions;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.permissions.ProjectPermission;
import com.google.gerrit.server.project.NoSuchProjectException;
@@ -49,7 +49,6 @@
private final Provider<CurrentUser> userProvider;
private final ProjectCache projectCache;
private final GitRepositoryManager repoManager;
- private final VisibleRefFilter.Factory visibleRefFilterFactory;
private final PermissionBackend permissionBackend;
@Inject
@@ -57,12 +56,10 @@
ProjectCache projectCache,
Provider<CurrentUser> userProvider,
GitRepositoryManager repoManager,
- VisibleRefFilter.Factory visibleRefFilterFactory,
PermissionBackend permissionBackend) {
this.userProvider = userProvider;
this.projectCache = projectCache;
this.repoManager = repoManager;
- this.visibleRefFilterFactory = visibleRefFilterFactory;
this.permissionBackend = permissionBackend;
}
@@ -73,11 +70,7 @@
throw new NoSuchProjectException(name);
}
return new FilteredRepository(
- projectState,
- userProvider.get(),
- repoManager.openRepository(name),
- visibleRefFilterFactory,
- permissionBackend);
+ projectState, userProvider.get(), repoManager.openRepository(name), permissionBackend);
}
}
@@ -88,7 +81,6 @@
ProjectState projectState,
CurrentUser user,
Repository delegate,
- VisibleRefFilter.Factory refFilterFactory,
PermissionBackend permissionBackend)
throws PermissionBackendException {
super(toBuilder(delegate));
@@ -106,7 +98,7 @@
this.refdb =
new FilteredRefDatabase(
- delegate.getRefDatabase(), refFilterFactory.create(projectState, delegate));
+ delegate, permissionBackend.user(user).project(projectState.getNameKey()));
}
}
@@ -152,7 +144,7 @@
}
@Override
- public void notifyIndexChanged() {
+ public void notifyIndexChanged(boolean internal) {
throw new UnsupportedOperationException(); // Gitiles is read-only.
}
@@ -167,12 +159,12 @@
}
private static class FilteredRefDatabase extends RefDatabase {
- private final RefDatabase delegate;
- private final VisibleRefFilter refFilter;
+ private final Repository git;
+ private final PermissionBackend.ForProject perm;
- private FilteredRefDatabase(RefDatabase delegate, VisibleRefFilter refFilter) {
- this.delegate = delegate;
- this.refFilter = refFilter;
+ private FilteredRefDatabase(Repository git, PermissionBackend.ForProject perm) {
+ this.git = git;
+ this.perm = perm;
}
@Override
@@ -187,7 +179,7 @@
@Override
public boolean isNameConflicting(String name) throws IOException {
- return delegate.isNameConflicting(name);
+ return git.getRefDatabase().isNameConflicting(name);
}
@Override
@@ -202,25 +194,50 @@
@Override
public Ref exactRef(String name) throws IOException {
- Ref ref = delegate.exactRef(name);
+ Ref ref = git.getRefDatabase().exactRef(name);
if (ref == null) {
return null;
}
- return refFilter.filter(ImmutableMap.of(name, ref), true).get(name);
+ try {
+ return perm.filter(
+ ImmutableMap.of(name, ref),
+ git,
+ RefFilterOptions.builder().setFilterTagsSeparately(true).build())
+ .get(name);
+ } catch (PermissionBackendException e) {
+ throw new IOException(e);
+ }
}
@Override
public Ref getRef(String name) throws IOException {
- Ref ref = delegate.getRef(name);
+ Ref ref = git.getRefDatabase().getRef(name);
if (ref == null) {
return null;
}
- return refFilter.filter(ImmutableMap.of(ref.getName(), ref), true).get(ref.getName());
+ try {
+ return perm.filter(
+ ImmutableMap.of(ref.getName(), ref),
+ git,
+ RefFilterOptions.builder().setFilterTagsSeparately(true).build())
+ .get(ref.getName());
+ } catch (PermissionBackendException e) {
+ throw new IOException(e);
+ }
}
@Override
public Map<String, Ref> getRefs(String prefix) throws IOException {
- Map<String, Ref> refs = refFilter.filter(delegate.getRefs(prefix), true);
+ Map<String, Ref> refs;
+ try {
+ refs =
+ perm.filter(
+ git.getRefDatabase().getRefs(prefix),
+ git,
+ RefFilterOptions.builder().setFilterTagsSeparately(true).build());
+ } catch (PermissionBackendException e) {
+ throw new IOException(e);
+ }
Map<String, Ref> result = Maps.newHashMapWithExpectedSize(refs.size());
for (Ref ref : refs.values()) {
// VisibleRefFilter adds the prefix to the keys, re-strip it.
@@ -231,7 +248,7 @@
@Override
public List<Ref> getAdditionalRefs() throws IOException {
- List<Ref> refs = delegate.getAdditionalRefs();
+ List<Ref> refs = git.getRefDatabase().getAdditionalRefs();
Map<String, Ref> result = Maps.newHashMapWithExpectedSize(refs.size());
for (Ref ref : refs) {
result.put(ref.getName(), ref);
@@ -241,7 +258,7 @@
@Override
public Ref peel(Ref ref) throws IOException {
- return delegate.peel(ref);
+ return git.getRefDatabase().peel(ref);
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitiles/GerritGitilesAccess.java b/src/main/java/com/googlesource/gerrit/plugins/gitiles/GerritGitilesAccess.java
index 3b5550a..3b833ba 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitiles/GerritGitilesAccess.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitiles/GerritGitilesAccess.java
@@ -24,10 +24,10 @@
import com.google.gerrit.server.config.AnonymousCowardName;
import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.permissions.PermissionBackendException;
-import com.google.gerrit.server.project.ListProjects;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectJson;
import com.google.gerrit.server.project.ProjectState;
+import com.google.gerrit.server.restapi.project.ListProjects;
import com.google.gitiles.GitilesAccess;
import com.google.gitiles.GitilesUrls;
import com.google.gitiles.RepositoryDescription;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitiles/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/gitiles/HttpModule.java
index 9402bf4..d91f831 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitiles/HttpModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitiles/HttpModule.java
@@ -14,6 +14,7 @@
package com.googlesource.gerrit.plugins.gitiles;
+import com.google.common.flogger.FluentLogger;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.config.SitePaths;
import com.google.gitiles.GitilesAccess;
@@ -43,8 +44,6 @@
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.transport.resolver.RepositoryResolver;
import org.eclipse.jgit.util.FS;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
class HttpModule extends ServletModule {
private final Provider<CurrentUser> userProvider;
@@ -86,7 +85,7 @@
};
}
- private static final Logger log = LoggerFactory.getLogger(HttpModule.class);
+ private static final FluentLogger log = FluentLogger.forEnclosingClass();
@Override
protected void configureServlets() {
@@ -127,7 +126,7 @@
if (cfg.getFile().exists()) {
cfg.load();
} else {
- log.info("No " + cfgFile.getAbsolutePath() + "; assuming defaults");
+ log.atInfo().log("No %s; assuming defaults", cfgFile.getAbsolutePath());
}
return cfg;
}