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


Java Result类代码示例

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


Result类属于org.eclipse.jgit.lib.RefUpdate包,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    Ref currentRef = repository.getTags().get(tagName);
    if (currentRef == null) {
        throw new GitException.MissingObjectException(tagName, GitObjectType.TAG);
    }
    String fullName = currentRef.getName();
    try {
        RefUpdate update = repository.updateRef(fullName);
        update.setRefLogMessage("tag deleted", false);
        update.setForceUpdate(true);
        Result deleteResult = update.delete();

        switch (deleteResult) {
            case IO_FAILURE:
            case LOCK_FAILURE:
            case REJECTED:
                throw new GitException.RefUpdateException("Cannot delete tag " + tagName, GitRefUpdateResult.valueOf(deleteResult.name()));
        }
    } catch (IOException ex) {
        throw new GitException(ex);
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:DeleteTagCommand.java

示例2: doRefUpdate

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@VisibleForTesting
static void doRefUpdate(org.eclipse.jgit.lib.Repository jGitRepository, RevWalk revWalk,
                        String ref, ObjectId commitId) throws IOException {

    if (ref.startsWith(Constants.R_TAGS)) {
        final Ref oldRef = jGitRepository.exactRef(ref);
        if (oldRef != null) {
            throw new StorageException("tag ref exists already: " + ref);
        }
    }

    final RefUpdate refUpdate = jGitRepository.updateRef(ref);
    refUpdate.setNewObjectId(commitId);

    final Result res = refUpdate.update(revWalk);
    switch (res) {
        case NEW:
        case FAST_FORWARD:
            // Expected
            break;
        default:
            throw new StorageException("unexpected refUpdate state: " + res);
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:25,代码来源:GitRepository.java

示例3: tagDelete

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Override
public void tagDelete(String name) throws GitException {
  try {
    Ref tagRef = repository.findRef(name);
    if (tagRef == null) {
      throw new GitException("Tag " + name + " not found. ");
    }

    RefUpdate updateRef = repository.updateRef(tagRef.getName());
    updateRef.setRefLogMessage("tag deleted", false);
    updateRef.setForceUpdate(true);
    Result deleteResult = updateRef.delete();
    if (deleteResult != Result.FORCED && deleteResult != Result.FAST_FORWARD) {
      throw new GitException(format(ERROR_TAG_DELETE, name, deleteResult));
    }
  } catch (IOException exception) {
    throw new GitException(exception.getMessage(), exception);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:JGitConnection.java

示例4: call

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Override
public RefUpdate.Result call() throws Exception {
  Ref ref = repo.exactRef(refName);
  afterReadRef.run();
  ObjectId oldId;
  if (ref == null) {
    oldId = ObjectId.zeroId();
  } else {
    oldId = ref.getObjectId();
    int next = parse(rw, oldId);
    if (next >= value) {
      // a concurrent write updated the ref already to this or a higher value
      return RefUpdate.Result.NO_CHANGE;
    }
  }
  return store(repo, rw, oldId, value);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:RepoSequence.java

示例5: store

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
private RefUpdate.Result store(Repository repo, RevWalk rw, @Nullable ObjectId oldId, int val)
    throws IOException {
  ObjectId newId;
  try (ObjectInserter ins = repo.newObjectInserter()) {
    newId = ins.insert(OBJ_BLOB, Integer.toString(val).getBytes(UTF_8));
    ins.flush();
  }
  RefUpdate ru = repo.updateRef(refName);
  if (oldId != null) {
    ru.setExpectedOldObjectId(oldId);
  }
  ru.disableRefLog();
  ru.setNewObjectId(newId);
  ru.setForceUpdate(true); // Required for non-commitish updates.
  RefUpdate.Result result = ru.update(rw);
  if (refUpdated(result)) {
    gitRefUpdated.fire(projectName, ru, null);
  }
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:RepoSequence.java

示例6: deleteUserBranch

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
public static void deleteUserBranch(
    Repository repo,
    Project.NameKey project,
    GitReferenceUpdated gitRefUpdated,
    @Nullable IdentifiedUser user,
    PersonIdent refLogIdent,
    Account.Id accountId)
    throws IOException {
  String refName = RefNames.refsUsers(accountId);
  Ref ref = repo.exactRef(refName);
  if (ref == null) {
    return;
  }

  RefUpdate ru = repo.updateRef(refName);
  ru.setExpectedOldObjectId(ref.getObjectId());
  ru.setNewObjectId(ObjectId.zeroId());
  ru.setForceUpdate(true);
  ru.setRefLogIdent(refLogIdent);
  ru.setRefLogMessage("Delete Account", true);
  Result result = ru.delete();
  if (result != Result.FORCED) {
    throw new IOException(String.format("Failed to delete ref %s: %s", refName, result.name()));
  }
  gitRefUpdated.fire(project, ru, user != null ? user.getAccount() : null);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:AccountsUpdate.java

示例7: createUserBranch

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
public void createUserBranch(
    Repository repo,
    ObjectInserter oi,
    ObjectId emptyTree,
    Account.Id accountId,
    Timestamp registeredOn)
    throws IOException {
  ObjectId id = createInitialEmptyCommit(oi, emptyTree, registeredOn);

  String refName = RefNames.refsUsers(accountId);
  RefUpdate ru = repo.updateRef(refName);
  ru.setExpectedOldObjectId(ObjectId.zeroId());
  ru.setNewObjectId(id);
  ru.setRefLogIdent(serverIdent);
  ru.setRefLogMessage(CREATE_ACCOUNT_MSG, false);
  Result result = ru.update();
  if (result != Result.NEW) {
    throw new IOException(String.format("Failed to update ref %s: %s", refName, result.name()));
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:Schema_146.java

示例8: pushForMasterWithMessage

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Test
public void pushForMasterWithMessage() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master/%m=my_test_message");
  r.assertOkStatus();
  r.assertChange(Change.Status.NEW, null);
  ChangeInfo ci = get(r.getChangeId(), MESSAGES, ALL_REVISIONS);
  Collection<ChangeMessageInfo> changeMessages = ci.messages;
  assertThat(changeMessages).hasSize(1);
  for (ChangeMessageInfo cm : changeMessages) {
    assertThat(cm.message).isEqualTo("Uploaded patch set 1.\nmy test message");
  }
  Collection<RevisionInfo> revisions = ci.revisions.values();
  assertThat(revisions).hasSize(1);
  for (RevisionInfo ri : revisions) {
    assertThat(ri.description).isEqualTo("my test message");
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:AbstractPushForReview.java

示例9: pushForMasterWithPercentEncodedMessage

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Test
public void pushForMasterWithPercentEncodedMessage() throws Exception {
  // Exercise percent-encoding of UTF-8, underscores, and patterns reserved by git-rev-parse.
  PushOneCommit.Result r =
      pushTo(
          "refs/for/master/%m="
              + "Punctu%2E%2e%2Eation%7E%2D%40%7Bu%7D%20%7C%20%28%E2%95%AF%C2%B0%E2%96%A1%C2%B0"
              + "%EF%BC%89%E2%95%AF%EF%B8%B5%20%E2%94%BB%E2%94%81%E2%94%BB%20%5E%5F%5E");
  r.assertOkStatus();
  r.assertChange(Change.Status.NEW, null);
  ChangeInfo ci = get(r.getChangeId(), MESSAGES, ALL_REVISIONS);
  Collection<ChangeMessageInfo> changeMessages = ci.messages;
  assertThat(changeMessages).hasSize(1);
  for (ChangeMessageInfo cm : changeMessages) {
    assertThat(cm.message)
        .isEqualTo("Uploaded patch set 1.\[email protected]{u} | (╯°□°)╯︵ ┻━┻ ^_^");
  }
  Collection<RevisionInfo> revisions = ci.revisions.values();
  assertThat(revisions).hasSize(1);
  for (RevisionInfo ri : revisions) {
    assertThat(ri.description).isEqualTo("[email protected]{u} | (╯°□°)╯︵ ┻━┻ ^_^");
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:AbstractPushForReview.java

示例10: pushForMasterWithInvalidPercentEncodedMessage

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Test
public void pushForMasterWithInvalidPercentEncodedMessage() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master/%m=not_percent_decodable_%%oops%20");
  r.assertOkStatus();
  r.assertChange(Change.Status.NEW, null);
  ChangeInfo ci = get(r.getChangeId(), MESSAGES, ALL_REVISIONS);
  Collection<ChangeMessageInfo> changeMessages = ci.messages;
  assertThat(changeMessages).hasSize(1);
  for (ChangeMessageInfo cm : changeMessages) {
    assertThat(cm.message).isEqualTo("Uploaded patch set 1.\nnot percent decodable %%oops%20");
  }
  Collection<RevisionInfo> revisions = ci.revisions.values();
  assertThat(revisions).hasSize(1);
  for (RevisionInfo ri : revisions) {
    assertThat(ri.description).isEqualTo("not percent decodable %%oops%20");
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:AbstractPushForReview.java

示例11: pushNewPatchsetToRefsChanges

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Test
public void pushNewPatchsetToRefsChanges() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master");
  r.assertOkStatus();
  PushOneCommit push =
      pushFactory.create(
          db,
          admin.getIdent(),
          testRepo,
          PushOneCommit.SUBJECT,
          "b.txt",
          "anotherContent",
          r.getChangeId());
  r = push.to("refs/changes/" + r.getChange().change().getId().get());
  r.assertOkStatus();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:AbstractPushForReview.java

示例12: pushNewPatchsetToPatchSetLockedChange

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Test
public void pushNewPatchsetToPatchSetLockedChange() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master");
  r.assertOkStatus();
  PushOneCommit push =
      pushFactory.create(
          db,
          admin.getIdent(),
          testRepo,
          PushOneCommit.SUBJECT,
          "b.txt",
          "anotherContent",
          r.getChangeId());
  revision(r).review(new ReviewInput().label("Patch-Set-Lock", 1));
  r = push.to("refs/for/master");
  r.assertErrorStatus("cannot add patch set to " + r.getChange().change().getChangeId() + ".");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:AbstractPushForReview.java

示例13: createNewChangeForAllNotInTarget

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Test
public void createNewChangeForAllNotInTarget() throws Exception {
  enableCreateNewChangeForAllNotInTarget();

  PushOneCommit push =
      pushFactory.create(
          db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "a.txt", "content");
  PushOneCommit.Result r = push.to("refs/for/master");
  r.assertOkStatus();

  push =
      pushFactory.create(
          db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent");
  r = push.to("refs/for/master");
  r.assertOkStatus();

  gApi.projects().name(project.get()).branch("otherBranch").create(new BranchInput());

  PushOneCommit.Result r2 = push.to("refs/for/otherBranch");
  r2.assertOkStatus();
  assertTwoChangesWithSameRevision(r);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:AbstractPushForReview.java

示例14: pushChangeBasedOnChangeOfOtherUserWithCreateNewChangeForAllNotInTarget

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Test
public void pushChangeBasedOnChangeOfOtherUserWithCreateNewChangeForAllNotInTarget()
    throws Exception {
  enableCreateNewChangeForAllNotInTarget();

  // create a change as admin
  PushOneCommit push =
      pushFactory.create(
          db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "a.txt", "content");
  PushOneCommit.Result r = push.to("refs/for/master");
  r.assertOkStatus();
  RevCommit commitChange1 = r.getCommit();

  // create a second change as user (depends on the change from admin)
  TestRepository<?> userRepo = cloneProject(project, user);
  GitUtil.fetch(userRepo, r.getPatchSet().getRefName() + ":change");
  userRepo.reset("change");
  push =
      pushFactory.create(
          db, user.getIdent(), userRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent");
  r = push.to("refs/for/master");
  r.assertOkStatus();

  // assert that no new change was created for the commit of the predecessor change
  assertThat(query(commitChange1.name())).hasSize(1);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:AbstractPushForReview.java

示例15: pushSameCommitTwiceUsingMagicBranchBaseOption

import org.eclipse.jgit.lib.RefUpdate.Result; //导入依赖的package包/类
@Test
public void pushSameCommitTwiceUsingMagicBranchBaseOption() throws Exception {
  grant(project, "refs/heads/master", Permission.PUSH);
  PushOneCommit.Result rBase = pushTo("refs/heads/master");
  rBase.assertOkStatus();

  gApi.projects().name(project.get()).branch("foo").create(new BranchInput());

  PushOneCommit push =
      pushFactory.create(
          db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent");

  PushOneCommit.Result r = push.to("refs/for/master");
  r.assertOkStatus();

  PushResult pr =
      GitUtil.pushHead(testRepo, "refs/for/foo%base=" + rBase.getCommit().name(), false, false);

  // BatchUpdate implementations differ in how they hook into progress monitors. We mostly just
  // care that there is a new change.
  assertThat(pr.getMessages()).containsMatch("changes: new: 1,( refs: 1)? done");
  assertTwoChangesWithSameRevision(r);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:AbstractPushForReview.java


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