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


Java ReceiveCommand类代码示例

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


ReceiveCommand类属于org.eclipse.jgit.transport包,在下文中一共展示了ReceiveCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: CreateBranch

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
@Inject
CreateBranch(
    Provider<IdentifiedUser> identifiedUser,
    PermissionBackend permissionBackend,
    GitRepositoryManager repoManager,
    GitReferenceUpdated referenceUpdated,
    RefValidationHelper.Factory refHelperFactory,
    CreateRefControl createRefControl,
    @Assisted String ref) {
  this.identifiedUser = identifiedUser;
  this.permissionBackend = permissionBackend;
  this.repoManager = repoManager;
  this.referenceUpdated = referenceUpdated;
  this.refCreationValidator = refHelperFactory.create(ReceiveCommand.Type.CREATE);
  this.createRefControl = createRefControl;
  this.ref = ref;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:CreateBranch.java

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

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

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

示例6: updateRepo

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
@Override
public void updateRepo(RepoContext ctx) throws Exception {
  commit = ctx.getRevWalk().parseCommit(commitId);
  ctx.getRevWalk().parseBody(commit);
  changeKind =
      changeKindCache.getChangeKind(
          projectState.getNameKey(),
          ctx.getRevWalk(),
          ctx.getRepoView().getConfig(),
          priorCommitId,
          commitId);

  if (checkMergedInto) {
    String mergedInto = findMergedInto(ctx, dest.get(), commit);
    if (mergedInto != null) {
      mergedByPushOp =
          mergedByPushOpFactory.create(requestScopePropagator, patchSetId, mergedInto);
    }
  }

  cmd = new ReceiveCommand(ObjectId.zeroId(), commitId, patchSetId.toRefName());
  ctx.addRefUpdate(cmd);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:ReplaceOp.java

示例7: isCommit

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
private boolean isCommit(ReceiveCommand cmd) {
  RevObject obj;
  try {
    obj = rp.getRevWalk().parseAny(cmd.getNewId());
  } catch (IOException err) {
    logError("Invalid object " + cmd.getNewId().name() + " for " + cmd.getRefName(), err);
    reject(cmd, "invalid object");
    return false;
  }

  if (obj instanceof RevCommit) {
    return true;
  }
  reject(cmd, "not a commit");
  return false;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:ReceiveCommits.java

示例8: parseDelete

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
private void parseDelete(ReceiveCommand cmd) throws PermissionBackendException {
  logDebug("Deleting {}", cmd);
  if (cmd.getRefName().startsWith(REFS_CHANGES)) {
    errors.put(ReceiveError.DELETE_CHANGES, cmd.getRefName());
    reject(cmd, "cannot delete changes");
  } else if (canDelete(cmd)) {
    if (!validRefOperation(cmd)) {
      return;
    }
    actualCommands.add(cmd);
  } else if (RefNames.REFS_CONFIG.equals(cmd.getRefName())) {
    reject(cmd, "cannot delete project configuration");
  } else {
    errors.put(ReceiveError.DELETE, cmd.getRefName());
    reject(cmd, "cannot delete references");
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:ReceiveCommits.java

示例9: MagicBranchInput

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
MagicBranchInput(
    IdentifiedUser user,
    ReceiveCommand cmd,
    LabelTypes labelTypes,
    NotesMigration notesMigration) {
  this.cmd = cmd;
  this.draft = cmd.getRefName().startsWith(MagicBranch.NEW_DRAFT_CHANGE);
  this.publish = cmd.getRefName().startsWith(MagicBranch.NEW_PUBLISH_CHANGE);
  this.labelTypes = labelTypes;
  this.notesMigration = notesMigration;
  GeneralPreferencesInfo prefs = user.getAccount().getGeneralPreferencesInfo();
  this.defaultPublishComments =
      prefs != null
          ? firstNonNull(
              user.getAccount().getGeneralPreferencesInfo().publishCommentsOnPush, false)
          : false;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:ReceiveCommits.java

示例10: requestReplace

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
private boolean requestReplace(
    ReceiveCommand cmd, boolean checkMergedInto, Change change, RevCommit newCommit) {
  if (change.getStatus().isClosed()) {
    reject(
        cmd,
        changeFormatter.changeClosed(
            ChangeReportFormatter.Input.builder().setChange(change).build()));
    return false;
  }

  ReplaceRequest req = new ReplaceRequest(change.getId(), newCommit, cmd, checkMergedInto);
  if (replaceByChange.containsKey(req.ontoChange)) {
    reject(cmd, "duplicate request");
    return false;
  }
  replaceByChange.put(req.ontoChange, req);
  return true;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:ReceiveCommits.java

示例11: setChangeId

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
private void setChangeId(int id) {
  boolean privateByDefault = projectCache.get(project.getNameKey()).isPrivateByDefault();

  changeId = new Change.Id(id);
  ins =
      changeInserterFactory
          .create(changeId, commit, refName)
          .setTopic(magicBranch.topic)
          .setPrivate(
              magicBranch.draft
                  || magicBranch.isPrivate
                  || (privateByDefault && !magicBranch.removePrivate))
          .setWorkInProgress(magicBranch.workInProgress)
          // Changes already validated in validateNewCommits.
          .setValidate(false);

  if (magicBranch.merged) {
    ins.setStatus(Change.Status.MERGED);
  }
  cmd = new ReceiveCommand(ObjectId.zeroId(), commit, ins.getPatchSetId().toRefName());
  if (rp.getPushCertificate() != null) {
    ins.setPushCertificate(rp.getPushCertificate().toTextWithSignature());
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:ReceiveCommits.java

示例12: ReplaceRequest

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
ReplaceRequest(
    Change.Id toChange, RevCommit newCommit, ReceiveCommand cmd, boolean checkMergedInto) {
  this.ontoChange = toChange;
  this.newCommitId = newCommit.copy();
  this.inputCommand = checkNotNull(cmd);
  this.checkMergedInto = checkMergedInto;

  revisions = HashBiMap.create();
  for (Ref ref : refs(toChange)) {
    try {
      revisions.forcePut(
          rp.getRevWalk().parseCommit(ref.getObjectId()), PatchSet.Id.fromRef(ref.getName()));
    } catch (IOException err) {
      logWarn(
          String.format(
              "Project %s contains invalid change ref %s", project.getName(), ref.getName()),
          err);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:ReceiveCommits.java

示例13: RefOperationValidators

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
@Inject
RefOperationValidators(
    PermissionBackend permissionBackend,
    AllUsersName allUsersName,
    DynamicSet<RefOperationValidationListener> refOperationValidationListeners,
    @Assisted Project project,
    @Assisted IdentifiedUser user,
    @Assisted ReceiveCommand cmd) {
  this.perm = permissionBackend.user(user);
  this.allUsersName = allUsersName;
  this.refOperationValidationListeners = refOperationValidationListeners;
  event = new RefReceivedEvent();
  event.command = cmd;
  event.project = project;
  event.user = user;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:RefOperationValidators.java

示例14: add

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
/**
 * Add a command.
 *
 * @param cmd command to add. If a command has been previously added for the same ref, the new
 *     SHA-1 of the most recent previous command must match the old SHA-1 of this command.
 */
public void add(ReceiveCommand cmd) {
  checkArgument(!cmd.getOldId().equals(cmd.getNewId()), "ref update is a no-op: %s", cmd);
  ReceiveCommand old = commands.get(cmd.getRefName());
  if (old == null) {
    commands.put(cmd.getRefName(), cmd);
    return;
  }
  checkArgument(
      old.getResult() == ReceiveCommand.Result.NOT_ATTEMPTED,
      "cannot chain ref update %s after update %s with result %s",
      cmd,
      old,
      old.getResult());
  checkArgument(
      cmd.getOldId().equals(old.getNewId()),
      "cannot chain ref update %s after update %s with different new ID",
      cmd,
      old);
  commands.put(
      cmd.getRefName(), new ReceiveCommand(old.getOldId(), cmd.getNewId(), cmd.getRefName()));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:28,代码来源:ChainedReceiveCommands.java

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


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