• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ReceiveCommand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: create

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
private static StagedResult create(
    Change.Id id, NoteDbChangeState.Delta delta, OpenRepo changeRepo, OpenRepo allUsersRepo) {
  ImmutableList<ReceiveCommand> changeCommands = ImmutableList.of();
  ImmutableList<InsertedObject> changeObjects = ImmutableList.of();
  if (changeRepo != null) {
    changeCommands = changeRepo.getCommandsSnapshot();
    changeObjects = changeRepo.getInsertedObjects();
  }
  ImmutableList<ReceiveCommand> allUsersCommands = ImmutableList.of();
  ImmutableList<InsertedObject> allUsersObjects = ImmutableList.of();
  if (allUsersRepo != null) {
    allUsersCommands = allUsersRepo.getCommandsSnapshot();
    allUsersObjects = allUsersRepo.getInsertedObjects();
  }
  return new AutoValue_NoteDbUpdateManager_StagedResult(
      id, delta,
      changeCommands, changeObjects,
      allUsersCommands, allUsersObjects);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:NoteDbUpdateManager.java


示例17: getDraftIds

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
private Table<Change.Id, Account.Id, ObjectId> getDraftIds() {
  Table<Change.Id, Account.Id, ObjectId> draftIds = HashBasedTable.create();
  if (allUsersRepo == null) {
    return draftIds;
  }
  for (ReceiveCommand cmd : allUsersRepo.getCommandsSnapshot()) {
    String r = cmd.getRefName();
    if (r.startsWith(REFS_DRAFT_COMMENTS)) {
      Change.Id changeId = Change.Id.fromRefPart(r.substring(REFS_DRAFT_COMMENTS.length()));
      Account.Id accountId = Account.Id.fromRefSuffix(r);
      checkDraftRef(accountId != null && changeId != null, r);
      draftIds.put(changeId, accountId, cmd.getNewId());
    }
  }
  return draftIds;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:NoteDbUpdateManager.java


示例18: doDelete

import org.eclipse.jgit.transport.ReceiveCommand; //导入依赖的package包/类
private void doDelete(Change.Id id) throws IOException {
  String metaRef = RefNames.changeMetaRef(id);
  Optional<ObjectId> old = changeRepo.cmds.get(metaRef);
  if (old.isPresent()) {
    changeRepo.cmds.add(new ReceiveCommand(old.get(), ObjectId.zeroId(), metaRef));
  }

  // Just scan repo for ref names, but get "old" values from cmds.
  for (Ref r :
      allUsersRepo.repo.getRefDatabase().getRefs(RefNames.refsDraftCommentsPrefix(id)).values()) {
    old = allUsersRepo.cmds.get(r.getName());
    if (old.isPresent()) {
      allUsersRepo.cmds.add(new ReceiveCommand(old.get(), ObjectId.zeroId(), r.getName()));
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:NoteDbUpdateManager.java


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Nammu类代码示例发布时间:2022-05-22
下一篇:
Java MockRestRequestMatchers类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap