in owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/GitRefListener.java [200:227]
public void processEvent(
Project.NameKey projectNameKey, Repository repository, Event event, Change.Id cId)
throws NoSuchProjectException {
Changes changes = api.changes();
// The provider injected by Gerrit is shared with other workers on the
// same local thread and thus cannot be closed in this event listener.
try {
ChangeApi cApi = changes.id(cId.get());
ChangeInfo change = cApi.get();
PatchList patchList = getPatchList(repository, event, change);
if (patchList != null) {
PathOwners owners = new PathOwners(accounts, repository, change.branch, patchList);
Set<Account.Id> allReviewers = Sets.newHashSet();
allReviewers.addAll(owners.get().values());
allReviewers.addAll(owners.getReviewers().values());
for (Matcher matcher : owners.getMatchers().values()) {
allReviewers.addAll(matcher.getOwners());
allReviewers.addAll(matcher.getReviewers());
}
logger.debug("Autoassigned reviewers are: {}", allReviewers.toString());
reviewerManager.addReviewers(projectNameKey, cApi, allReviewers);
}
} catch (RestApiException e) {
logger.warn("Could not open change: {}", cId, e);
} catch (ReviewerManagerException e) {
logger.warn("Could not add reviewers for change: {}", cId, e);
}
}