Fix trivial usages of deprecated RefDatabase.getRefs method

getRefs(String) returns Map<String, Ref>; most callers only call its
values() method and iterate over the list of Ref objects. It's trivial
to replace those calls with getRefsByPrefix which returns a List<Ref>.

Change-Id: Iad142ea8a0dec69b22fcec084bb66eafd79c2a0d
This commit is contained in:
David Pursehouse
2018-06-01 19:55:16 +09:00
parent 895d678b4f
commit f717f06986
26 changed files with 34 additions and 40 deletions

View File

@@ -18,7 +18,7 @@ import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.data.Capable;
import com.google.gerrit.reviewdb.client.Project;
import java.io.IOException;
import java.util.Map;
import java.util.List;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
@@ -89,9 +89,9 @@ public final class MagicBranch {
}
private static Capable checkMagicBranchRef(String branchName, Repository repo, Project project) {
Map<String, Ref> blockingFors;
List<Ref> blockingFors;
try {
blockingFors = repo.getRefDatabase().getRefs(branchName);
blockingFors = repo.getRefDatabase().getRefsByPrefix(branchName);
} catch (IOException err) {
String projName = project.getName();
logger.atWarning().withCause(err).log("Cannot scan refs in '%s'", projName);
@@ -101,7 +101,7 @@ public final class MagicBranch {
String projName = project.getName();
logger.atSevere().log(
"Repository '%s' needs the following refs removed to receive changes: %s",
projName, blockingFors.keySet());
projName, blockingFors);
return new Capable("One or more " + branchName + " names blocks change upload");
}