Search in sources :

Example 1 with BatchUpdateListener

use of com.google.gerrit.server.update.BatchUpdateListener in project gerrit by GerritCodeReview.

the class NoteDbUpdateManager method execute.

private BatchRefUpdate execute(OpenRepo or, boolean dryrun, @Nullable PushCertificate pushCert) throws IOException {
    if (or == null || or.cmds.isEmpty()) {
        return null;
    }
    if (!dryrun) {
        or.flush();
    } else {
        // OpenRepo buffers objects separately; caller may assume that objects are available in the
        // inserter it previously passed via setChangeRepo.
        or.flushToFinalInserter();
    }
    BatchRefUpdate bru = or.repo.getRefDatabase().newBatchUpdate();
    bru.setPushCertificate(pushCert);
    if (refLogMessage != null) {
        bru.setRefLogMessage(refLogMessage, false);
    } else {
        bru.setRefLogMessage(firstNonNull(NoteDbUtil.guessRestApiHandler(), "Update NoteDb refs"), false);
    }
    bru.setRefLogIdent(refLogIdent != null ? refLogIdent : serverIdent.get());
    bru.setAtomic(true);
    or.cmds.addTo(bru);
    bru.setAllowNonFastForwards(allowNonFastForwards(or.cmds));
    for (BatchUpdateListener listener : batchUpdateListeners) {
        bru = listener.beforeUpdateRefs(bru);
    }
    if (!dryrun) {
        RefUpdateUtil.executeChecked(bru, or.rw);
    }
    return bru;
}
Also used : BatchRefUpdate(org.eclipse.jgit.lib.BatchRefUpdate) BatchUpdateListener(com.google.gerrit.server.update.BatchUpdateListener)

Aggregations

BatchUpdateListener (com.google.gerrit.server.update.BatchUpdateListener)1 BatchRefUpdate (org.eclipse.jgit.lib.BatchRefUpdate)1