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


Java ReceiveCommand.setResult方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: validateNewCommits

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
private void validateNewCommits(Branch.NameKey branch, ReceiveCommand cmd)
    throws PermissionBackendException {
  PermissionBackend.ForRef perm = permissions.ref(branch.get());
  if (!RefNames.REFS_CONFIG.equals(cmd.getRefName())
      && !(MagicBranch.isMagicBranch(cmd.getRefName())
          || NEW_PATCHSET_PATTERN.matcher(cmd.getRefName()).matches())
      && pushOptions.containsKey(PUSH_OPTION_SKIP_VALIDATION)) {
    try {
      perm.check(RefPermission.SKIP_VALIDATION);
      if (!Iterables.isEmpty(rejectCommits)) {
        throw new AuthException("reject-commits prevents " + PUSH_OPTION_SKIP_VALIDATION);
      }
      logDebug("Short-circuiting new commit validation");
    } catch (AuthException denied) {
      reject(cmd, denied.getMessage());
    }
    return;
  }

  boolean missingFullName = Strings.isNullOrEmpty(user.getAccount().getFullName());
  RevWalk walk = rp.getRevWalk();
  walk.reset();
  walk.sort(RevSort.NONE);
  try {
    RevObject parsedObject = walk.parseAny(cmd.getNewId());
    if (!(parsedObject instanceof RevCommit)) {
      return;
    }
    ListMultimap<ObjectId, Ref> existing = changeRefsById();
    walk.markStart((RevCommit) parsedObject);
    markHeadsAsUninteresting(walk, cmd.getRefName());
    int limit = receiveConfig.maxBatchCommits;
    int n = 0;
    for (RevCommit c; (c = walk.next()) != null; ) {
      if (++n > limit) {
        logDebug("Number of new commits exceeds limit of {}", limit);
        addMessage(
            "Cannot push more than "
                + limit
                + " commits to "
                + branch.get()
                + " without "
                + PUSH_OPTION_SKIP_VALIDATION
                + " option");
        reject(cmd, "too many commits");
        return;
      }
      if (existing.keySet().contains(c)) {
        continue;
      } else if (!validCommit(walk, perm, branch, cmd, c)) {
        break;
      }

      if (missingFullName && user.hasEmailAddress(c.getCommitterIdent().getEmailAddress())) {
        logDebug("Will update full name of caller");
        setFullNameTo = c.getCommitterIdent().getName();
        missingFullName = false;
      }
    }
    logDebug("Validated {} new commits", n);
  } catch (IOException err) {
    cmd.setResult(REJECTED_MISSING_OBJECT);
    logError("Invalid pack upload; one or more objects weren't sent", err);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:66,代码来源:ReceiveCommits.java

示例6: reject

import org.eclipse.jgit.transport.ReceiveCommand; //导入方法依赖的package包/类
private void reject(@Nullable ReceiveCommand cmd, String why) {
  if (cmd != null) {
    cmd.setResult(REJECTED_OTHER_REASON, why);
    commandProgress.update(1);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:7,代码来源:ReceiveCommits.java


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