当前位置: 首页>>代码示例>>Java>>正文


Java ReceiveCommand.getResult方法代码示例

本文整理汇总了Java中org.eclipse.jgit.transport.ReceiveCommand.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java ReceiveCommand.getResult方法的具体用法?Java ReceiveCommand.getResult怎么用?Java ReceiveCommand.getResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.transport.ReceiveCommand的用法示例。


在下文中一共展示了ReceiveCommand.getResult方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: appendAndLogErrorMessage

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
private void appendAndLogErrorMessage(StringBuilder errorMessages, ReceiveCommand cmd) {
  String msg = null;
  switch (cmd.getResult()) {
    case REJECTED_CURRENT_BRANCH:
      msg = format("Cannot delete %s: it is the current branch", cmd.getRefName());
      break;
    case REJECTED_OTHER_REASON:
      msg = format("Cannot delete %s: %s", cmd.getRefName(), cmd.getMessage());
      break;
    case LOCK_FAILURE:
    case NOT_ATTEMPTED:
    case OK:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_NOCREATE:
    case REJECTED_NODELETE:
    case REJECTED_NONFASTFORWARD:
    default:
      msg = format("Cannot delete %s: %s", cmd.getRefName(), cmd.getResult());
      break;
  }
  log.error(msg);
  errorMessages.append(msg);
  errorMessages.append("\n");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:DeleteRef.java

示例2: updateReferenceWithNameChange

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
private void updateReferenceWithNameChange(
    Repository repository,
    String currentRefName,
    ObjectId currentObjectId,
    String newRefName,
    ObjectId targetObjectId,
    Timestamp timestamp)
    throws IOException {
  BatchRefUpdate batchRefUpdate = repository.getRefDatabase().newBatchUpdate();
  batchRefUpdate.addCommand(new ReceiveCommand(ObjectId.zeroId(), targetObjectId, newRefName));
  batchRefUpdate.addCommand(
      new ReceiveCommand(currentObjectId, ObjectId.zeroId(), currentRefName));
  batchRefUpdate.setRefLogMessage("rebase edit", false);
  batchRefUpdate.setRefLogIdent(getRefLogIdent(timestamp));
  try (RevWalk revWalk = new RevWalk(repository)) {
    batchRefUpdate.execute(revWalk, NullProgressMonitor.INSTANCE);
  }
  for (ReceiveCommand cmd : batchRefUpdate.getCommands()) {
    if (cmd.getResult() != ReceiveCommand.Result.OK) {
      throw new IOException("failed: " + cmd);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:ChangeEditModifier.java

示例3: unstarAll

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
public void unstarAll(Project.NameKey project, Change.Id changeId) throws OrmException {
  try (Repository repo = repoManager.openRepository(allUsers);
      RevWalk rw = new RevWalk(repo)) {
    BatchRefUpdate batchUpdate = repo.getRefDatabase().newBatchUpdate();
    batchUpdate.setAllowNonFastForwards(true);
    batchUpdate.setRefLogIdent(serverIdent);
    batchUpdate.setRefLogMessage("Unstar change " + changeId.get(), true);
    for (Account.Id accountId : byChangeFromIndex(changeId).keySet()) {
      String refName = RefNames.refsStarredChanges(changeId, accountId);
      Ref ref = repo.getRefDatabase().getRef(refName);
      batchUpdate.addCommand(new ReceiveCommand(ref.getObjectId(), ObjectId.zeroId(), refName));
    }
    batchUpdate.execute(rw, NullProgressMonitor.INSTANCE);
    for (ReceiveCommand command : batchUpdate.getCommands()) {
      if (command.getResult() != ReceiveCommand.Result.OK) {
        throw new IOException(
            String.format(
                "Unstar change %d failed, ref %s could not be deleted: %s",
                changeId.get(), command.getRefName(), command.getResult()));
      }
    }
    indexer.index(dbProvider.get(), project, changeId);
  } catch (IOException e) {
    throw new OrmException(String.format("Unstar change %d failed", changeId.get()), e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:StarredChangesUtil.java

示例4: onPreReceive

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
@Override
public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
  Worker w = new Worker(commands);
  try {
    w.progress.waitFor(
        executor.submit(scopePropagator.wrap(w)), timeoutMillis, TimeUnit.MILLISECONDS);
  } catch (ExecutionException e) {
    log.warn(
        String.format(
            "Error in ReceiveCommits while processing changes for project %s",
            projectState.getName()),
        e);
    rp.sendError("internal error while processing changes");
    // ReceiveCommits has tried its best to catch errors, so anything at this
    // point is very bad.
    for (ReceiveCommand c : commands) {
      if (c.getResult() == Result.NOT_ATTEMPTED) {
        c.setResult(Result.REJECTED_OTHER_REASON, "internal error");
      }
    }
  } finally {
    w.sendMessages();
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:AsyncReceiveCommits.java

示例5: executeNoteDbUpdate

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
private void executeNoteDbUpdate(RevWalk rw, ObjectInserter ins, BatchRefUpdate bru)
    throws IOException {
  if (bru.getCommands().isEmpty()) {
    logDebug("No commands, skipping flush and ref update");
    return;
  }
  ins.flush();
  bru.setAllowNonFastForwards(true);
  bru.execute(rw, NullProgressMonitor.INSTANCE);
  for (ReceiveCommand cmd : bru.getCommands()) {
    // TODO(dborowitz): LOCK_FAILURE for NoteDb primary should be retried.
    if (cmd.getResult() != ReceiveCommand.Result.OK) {
      throw new IOException("Update failed: " + bru);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:ReviewDbBatchUpdate.java

示例6: fire

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
public void fire(Project.NameKey project, BatchRefUpdate batchRefUpdate, Account updater) {
  if (!listeners.iterator().hasNext()) {
    return;
  }
  for (ReceiveCommand cmd : batchRefUpdate.getCommands()) {
    if (cmd.getResult() == ReceiveCommand.Result.OK) {
      fire(
          project,
          cmd.getRefName(),
          cmd.getOldId(),
          cmd.getNewId(),
          cmd.getType(),
          util.accountInfo(updater));
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:GitReferenceUpdated.java

示例7: deleteAllDraftsFromAllUsers

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
public void deleteAllDraftsFromAllUsers(Change.Id changeId) throws IOException {
  try (Repository repo = repoManager.openRepository(allUsers);
      RevWalk rw = new RevWalk(repo)) {
    BatchRefUpdate bru = repo.getRefDatabase().newBatchUpdate();
    for (Ref ref : getDraftRefs(repo, changeId)) {
      bru.addCommand(new ReceiveCommand(ref.getObjectId(), ObjectId.zeroId(), ref.getName()));
    }
    bru.setRefLogMessage("Delete drafts from NoteDb", false);
    bru.execute(rw, NullProgressMonitor.INSTANCE);
    for (ReceiveCommand cmd : bru.getCommands()) {
      if (cmd.getResult() != ReceiveCommand.Result.OK) {
        throw new IOException(
            String.format(
                "Failed to delete draft comment ref %s at %s: %s (%s)",
                cmd.getRefName(), cmd.getOldId(), cmd.getResult(), cmd.getMessage()));
      }
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:CommentsUtil.java

示例8: reject

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
private static void reject(Collection<ReceiveCommand> commands, String reason) {
  for (ReceiveCommand cmd : commands) {
    if (cmd.getResult() == ReceiveCommand.Result.NOT_ATTEMPTED) {
      cmd.setResult(ReceiveCommand.Result.REJECTED_OTHER_REASON, reason);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:SignedPushPreReceiveHook.java

示例9: checkResults

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
/**
 * Check results of all commands in the update batch, reducing to a single exception if there was
 * a failure.
 *
 * <p>Throws {@link LockFailureException} if at least one command failed with {@code
 * LOCK_FAILURE}, and the entire transaction was aborted, i.e. any non-{@code LOCK_FAILURE}
 * results, if there were any, failed with "transaction aborted".
 *
 * <p>In particular, if the underlying ref database does not {@link
 * org.eclipse.jgit.lib.RefDatabase#performsAtomicTransactions() perform atomic transactions},
 * then a combination of {@code LOCK_FAILURE} on one ref and {@code OK} or another result on other
 * refs will <em>not</em> throw {@code LockFailureException}.
 *
 * @param bru batch update; should already have been executed.
 * @throws LockFailureException if the transaction was aborted due to lock failure.
 * @throws IOException if any result was not {@code OK}.
 */
@VisibleForTesting
static void checkResults(BatchRefUpdate bru) throws IOException {
  if (bru.getCommands().isEmpty()) {
    return;
  }

  int lockFailure = 0;
  int aborted = 0;
  int failure = 0;

  for (ReceiveCommand cmd : bru.getCommands()) {
    if (cmd.getResult() != ReceiveCommand.Result.OK) {
      failure++;
    }
    if (cmd.getResult() == ReceiveCommand.Result.LOCK_FAILURE) {
      lockFailure++;
    } else if (cmd.getResult() == ReceiveCommand.Result.REJECTED_OTHER_REASON
        && JGitText.get().transactionAborted.equals(cmd.getMessage())) {
      aborted++;
    }
  }

  if (lockFailure + aborted == bru.getCommands().size()) {
    throw new LockFailureException("Update aborted with one or more lock failures: " + bru, bru);
  } else if (failure > 0) {
    throw new IOException("Update failed: " + bru);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:46,代码来源:RefUpdateUtil.java

示例10: executeRefUpdates

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
private void executeRefUpdates(boolean dryrun) throws IOException, RestApiException {
  if (getRefUpdates().isEmpty()) {
    logDebug("No ref updates to execute");
    return;
  }
  // May not be opened if the caller added ref updates but no new objects.
  // TODO(dborowitz): Really?
  initRepository();
  batchRefUpdate = repoView.getRepository().getRefDatabase().newBatchUpdate();
  batchRefUpdate.setPushCertificate(pushCert);
  batchRefUpdate.setRefLogMessage(refLogMessage, true);
  batchRefUpdate.setAllowNonFastForwards(true);
  repoView.getCommands().addTo(batchRefUpdate);
  if (user.isIdentifiedUser()) {
    batchRefUpdate.setRefLogIdent(user.asIdentifiedUser().newRefLogIdent(when, tz));
  }
  logDebug("Executing batch of {} ref updates", batchRefUpdate.getCommands().size());
  if (dryrun) {
    return;
  }

  // Force BatchRefUpdate to read newly referenced objects using a new RevWalk, rather than one
  // that might have access to unflushed objects.
  try (RevWalk updateRw = new RevWalk(repoView.getRepository())) {
    batchRefUpdate.execute(updateRw, NullProgressMonitor.INSTANCE);
  }
  boolean ok = true;
  for (ReceiveCommand cmd : batchRefUpdate.getCommands()) {
    if (cmd.getResult() != ReceiveCommand.Result.OK) {
      ok = false;
      break;
    }
  }
  if (!ok) {
    throw new RestApiException("BatchRefUpdate failed: " + batchRefUpdate);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:38,代码来源:ReviewDbBatchUpdate.java

示例11: execute

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
private void execute(Repository git, BatchRefUpdate bru) throws IOException {
  try (RevWalk rw = new RevWalk(git)) {
    bru.execute(rw, NullProgressMonitor.INSTANCE);
  }
  for (ReceiveCommand cmd : bru.getCommands()) {
    if (cmd.getResult() != ReceiveCommand.Result.OK) {
      throw new IOException("Failed to initialize " + allProjectsName + " refs:\n" + bru);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:AllProjectsCreator.java

示例12: executeCommands

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
@Override
protected void executeCommands() {
    if (getRepository().getRefDatabase() instanceof RefTreeDatabase) {
        List<ReceiveCommand> toApply = filterCommands(ReceiveCommand.Result.NOT_ATTEMPTED);
        if (toApply.isEmpty()) {
            return;
        }
        final BatchRefUpdate batch = ((RefTreeDatabase) getRepository().getRefDatabase()).getBootstrap().newBatchUpdate();
        batch.setAllowNonFastForwards(true);
        batch.setAtomic(false);
        batch.setRefLogIdent(getRefLogIdent());
        batch.setRefLogMessage("push",
                               true); //$NON-NLS-1$
        batch.addCommand(toApply);
        try {
            batch.setPushCertificate(getPushCertificate());
            batch.execute(getRevWalk(),
                          NullProgressMonitor.INSTANCE);
        } catch (IOException err) {
            for (ReceiveCommand cmd : toApply) {
                if (cmd.getResult() == ReceiveCommand.Result.NOT_ATTEMPTED) {
                    cmd.setResult(ReceiveCommand.Result.REJECTED_OTHER_REASON,
                                  MessageFormat.format(
                                          JGitText.get().lockError,
                                          err.getMessage()));
                }
            }
        }
    } else {
        super.executeCommands();
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:33,代码来源:KetchCustomReceivePack.java

示例13: processCommands

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
void processCommands(Collection<ReceiveCommand> commands, MultiProgressMonitor progress) {
  newProgress = progress.beginSubTask("new", UNKNOWN);
  replaceProgress = progress.beginSubTask("updated", UNKNOWN);
  closeProgress = progress.beginSubTask("closed", UNKNOWN);
  commandProgress = progress.beginSubTask("refs", UNKNOWN);

  try {
    parseCommands(commands);
  } catch (PermissionBackendException | NoSuchProjectException | IOException err) {
    for (ReceiveCommand cmd : actualCommands) {
      if (cmd.getResult() == NOT_ATTEMPTED) {
        cmd.setResult(REJECTED_OTHER_REASON, "internal server error");
      }
    }
    logError(String.format("Failed to process refs in %s", project.getName()), err);
  }
  if (magicBranch != null && magicBranch.cmd.getResult() == NOT_ATTEMPTED) {
    selectNewAndReplacedChangesFromMagicBranch();
  }
  preparePatchSetsForReplace();
  insertChangesAndPatchSets();
  newProgress.end();
  replaceProgress.end();

  if (!errors.isEmpty()) {
    logDebug("Handling error conditions: {}", errors.keySet());
    for (ReceiveError error : errors.keySet()) {
      rp.sendMessage(buildError(error, errors.get(error)));
    }
    rp.sendMessage(String.format("User: %s", displayName(user)));
    rp.sendMessage(COMMAND_REJECTION_MESSAGE_FOOTER);
  }

  Set<Branch.NameKey> branches = new HashSet<>();
  for (ReceiveCommand c : actualCommands) {
    // Most post-update steps should happen in UpdateOneRefOp#postUpdate. The only steps that
    // should happen in this loop are things that can't happen within one BatchUpdate because they
    // involve kicking off an additional BatchUpdate.
    if (c.getResult() != OK) {
      continue;
    }
    if (isHead(c) || isConfig(c)) {
      switch (c.getType()) {
        case CREATE:
        case UPDATE:
        case UPDATE_NONFASTFORWARD:
          autoCloseChanges(c);
          branches.add(new Branch.NameKey(project.getNameKey(), c.getRefName()));
          break;

        case DELETE:
          break;
      }
    }
  }

  // Update superproject gitlinks if required.
  if (!branches.isEmpty()) {
    try (MergeOpRepoManager orm = ormProvider.get()) {
      orm.setContext(db, TimeUtil.nowTs(), user, receiveId);
      SubmoduleOp op = subOpFactory.create(branches, orm);
      op.updateSuperProjects();
    } catch (SubmoduleException e) {
      logError("Can't update the superprojects", e);
    }
  }

  // Update account info with details discovered during commit walking.
  updateAccountInfo();

  closeProgress.end();
  commandProgress.end();
  progress.end();
  reportMessages();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:76,代码来源:ReceiveCommits.java


注:本文中的org.eclipse.jgit.transport.ReceiveCommand.getResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。