private void createCodeReviewNote()

in src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java [252:289]


  private void createCodeReviewNote(ChangeNotes notes, PatchSet ps, HeaderFormatter fmt)
      throws NoSuchChangeException {
    // This races with the label normalization/writeback done by MergeOp. It may
    // repeat some work, but results should be identical except in the case of
    // an additional race with a permissions change.
    // TODO(dborowitz): These will eventually be stamped in the ChangeNotes at
    // commit time so we will be able to skip this normalization step.
    Change change = notes.getChange();
    PatchSetApproval submit = null;
    for (PatchSetApproval a : approvalsUtil.byPatchSet(notes, ps.id())) {
      if (a.value() == 0) {
        // Ignore 0 values.
      } else if (a.isLegacySubmit()) {
        submit = a;
      } else {
        Optional<LabelType> type = labelTypes.byLabel(a.labelId());
        if (type.isPresent()) {
          fmt.appendApproval(
              type.get(),
              a.value(),
              a.accountId(),
              accountCache.get(a.accountId()).map(AccountState::account));
        }
      }
    }
    if (submit != null) {
      fmt.appendSubmittedBy(
          submit.accountId(), accountCache.get(submit.accountId()).map(AccountState::account));
      fmt.appendSubmittedAt(submit.granted());
    }

    UrlFormatter uf = urlFormatter.get();
    if (uf != null && uf.getWebUrl().isPresent()) {
      fmt.appendReviewedOn(uf, notes.getChange().getProject(), ps.id().changeId());
    }
    fmt.appendProject(project.get());
    fmt.appendBranch(change.getDest().branch());
  }