use of com.google.gerrit.extensions.config.ExternalIncludedIn in project gerrit by GerritCodeReview.
the class IncludedIn method apply.
public IncludedInInfo apply(Project.NameKey project, String revisionId) throws RestApiException, IOException {
try (Repository r = repoManager.openRepository(project);
RevWalk rw = new RevWalk(r)) {
rw.setRetainBody(false);
RevCommit rev;
try {
rev = rw.parseCommit(ObjectId.fromString(revisionId));
} catch (IncorrectObjectTypeException err) {
throw new BadRequestException(err.getMessage());
} catch (MissingObjectException err) {
throw new ResourceConflictException(err.getMessage());
}
IncludedInResolver.Result d = IncludedInResolver.resolve(r, rw, rev);
ListMultimap<String, String> external = MultimapBuilder.hashKeys().arrayListValues().build();
for (ExternalIncludedIn ext : externalIncludedIn) {
ListMultimap<String, String> extIncludedIns = ext.getIncludedIn(project.get(), rev.name(), d.getTags(), d.getBranches());
if (extIncludedIns != null) {
external.putAll(extIncludedIns);
}
}
return new IncludedInInfo(d.getBranches(), d.getTags(), (!external.isEmpty() ? external.asMap() : null));
}
}
Aggregations