ListTags: Avoid RefDatabase#getRefs
Change-Id: I10ce05cfda55a014226196f5638aaaaad718c3e9
This commit is contained in:
@@ -17,7 +17,7 @@ package com.google.gerrit.server.restapi.project;
|
||||
import static com.google.gerrit.reviewdb.client.RefNames.isConfigRef;
|
||||
import static java.util.Comparator.comparing;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectApi.ListRefsRequest;
|
||||
import com.google.gerrit.extensions.api.projects.TagInfo;
|
||||
import com.google.gerrit.extensions.common.WebLinkInfo;
|
||||
@@ -127,7 +127,8 @@ public class ListTags implements RestReadView<ProjectResource> {
|
||||
try (Repository repo = getRepository(resource.getNameKey());
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
Map<String, Ref> all =
|
||||
visibleTags(resource.getNameKey(), repo, repo.getRefDatabase().getRefs(Constants.R_TAGS));
|
||||
visibleTags(
|
||||
resource.getNameKey(), repo, repo.getRefDatabase().getRefsByPrefix(Constants.R_TAGS));
|
||||
for (Ref ref : all.values()) {
|
||||
tags.add(
|
||||
createTagInfo(perm.ref(ref.getName()), ref, rw, resource.getProjectState(), links));
|
||||
@@ -154,8 +155,7 @@ public class ListTags implements RestReadView<ProjectResource> {
|
||||
}
|
||||
Ref ref = repo.getRefDatabase().exactRef(tagName);
|
||||
if (ref != null
|
||||
&& !visibleTags(resource.getNameKey(), repo, ImmutableMap.of(ref.getName(), ref))
|
||||
.isEmpty()) {
|
||||
&& !visibleTags(resource.getNameKey(), repo, ImmutableList.of(ref)).isEmpty()) {
|
||||
return createTagInfo(
|
||||
permissionBackend
|
||||
.user(resource.getUser())
|
||||
@@ -221,8 +221,7 @@ public class ListTags implements RestReadView<ProjectResource> {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Ref> visibleTags(
|
||||
Project.NameKey project, Repository repo, Map<String, Ref> tags)
|
||||
private Map<String, Ref> visibleTags(Project.NameKey project, Repository repo, List<Ref> tags)
|
||||
throws PermissionBackendException {
|
||||
return permissionBackend
|
||||
.currentUser()
|
||||
|
||||
Reference in New Issue
Block a user