Adjust to core moving to List interface for ref filtering
Change I1f60c3ca0 changed the API to List interface for ref filtering.
Change-Id: I90e73625bd8276e13cf373ad9360b5658cb61516
diff --git a/src/main/java/com/googlesource/gerrit/modules/gitrefsfilter/ForProjectWrapper.java b/src/main/java/com/googlesource/gerrit/modules/gitrefsfilter/ForProjectWrapper.java
index 23078db..0544665 100644
--- a/src/main/java/com/googlesource/gerrit/modules/gitrefsfilter/ForProjectWrapper.java
+++ b/src/main/java/com/googlesource/gerrit/modules/gitrefsfilter/ForProjectWrapper.java
@@ -32,11 +32,10 @@
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
import org.eclipse.jgit.lib.Ref;
@@ -81,17 +80,18 @@
}
@Override
- public Map<String, Ref> filter(Map<String, Ref> refs, Repository repo, RefFilterOptions opts)
+ public Collection<Ref> filter(Collection<Ref> refs, Repository repo, RefFilterOptions opts)
throws PermissionBackendException {
- Map<String, Ref> filteredRefs = new HashMap<>();
- Map<String, Ref> defaultFilteredRefs =
+ Collection<Ref> filteredRefs = new ArrayList<>();
+ Collection<Ref> defaultFilteredRefs =
defaultForProject.filter(refs, repo, opts); // FIXME: can we filter the closed refs here?
Set<String> openChangesRefs = openChangesByScan(repo);
- for (String changeKey : defaultFilteredRefs.keySet()) {
- if (!isChangeRef(changeKey)
- || (isOpen(openChangesRefs, changeKey) && !isChangeMetaRef(changeKey))) {
- filteredRefs.put(changeKey, defaultFilteredRefs.get(changeKey));
+ for (Ref ref : defaultFilteredRefs) {
+ String refName = ref.getName();
+ if (!isChangeRef(refName)
+ || (isOpen(openChangesRefs, refName) && !isChangeMetaRef(refName))) {
+ filteredRefs.add(ref);
}
}