in java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java [507:526]
public RemoteFile readFileWithMode(String uriStr, String ref, String path)
throws GitAPIException, IOException {
// When the remote is fetch="<relative path>" the manifest parser uses a repoName as URI.
// Do a poor man's guessing if we have a repoName or URI
Repository repo =
uriStr.contains("://")
? repoManager.openByUri(uriStr)
: repoManager.openByName(Project.nameKey(uriStr));
Ref r = repo.findRef(ref);
ObjectId objectId = r == null ? repo.resolve(ref) : r.getObjectId();
if (objectId == null) {
throw new RevisionSyntaxException(
String.format("repo %s does not have ref %s", repo.toString(), ref), ref);
}
RevCommit commit = repo.parseCommit(objectId);
TreeWalk tw = TreeWalk.forPath(repo, path, commit.getTree());
return new RemoteFile(
tw.getObjectReader().open(tw.getObjectId(0)).getCachedBytes(Integer.MAX_VALUE),
tw.getFileMode(0));
}