Replace non-trivial uses of RefDatabase.getRefs with getRefsByPrefix

getRefs returns Map<String, Ref> where the key is the ref name with the
given prefix stripped off. However, getRefsByPrefix returns a list of
Refs with the full refname.

Therefore, when converting to getRefsByPrefix, we have to explicitly
remove the ref prefix from each ref name before using it.

Change-Id: I9a3ecf942ea47325fffa27596265fde217c2af0c
This commit is contained in:
David Pursehouse
2018-06-02 19:08:28 +09:00
parent f717f06986
commit 8d36f77af5
3 changed files with 16 additions and 12 deletions

View File

@@ -296,7 +296,11 @@ public class StarredChangesUtil {
private static Set<String> getRefNames(Repository repo, String prefix) throws IOException {
RefDatabase refDb = repo.getRefDatabase();
return refDb.getRefs(prefix).keySet();
return refDb
.getRefsByPrefix(prefix)
.stream()
.map(r -> r.getName().substring(prefix.length()))
.collect(toSet());
}
public ObjectId getObjectId(Account.Id accountId, Change.Id changeId) {