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

Java RefUpdate类代码示例

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

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



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

示例1: run

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的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; //导入依赖的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: testDoUpdateRef

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
private static void testDoUpdateRef(String ref, ObjectId commitId, boolean tagExists) throws Exception {
    final org.eclipse.jgit.lib.Repository jGitRepo = mock(org.eclipse.jgit.lib.Repository.class);
    final RevWalk revWalk = mock(RevWalk.class);
    final RefUpdate refUpdate = mock(RefUpdate.class);

    when(jGitRepo.exactRef(ref)).thenReturn(tagExists ? mock(Ref.class) : null);
    when(jGitRepo.updateRef(ref)).thenReturn(refUpdate);

    when(refUpdate.update(revWalk)).thenReturn(RefUpdate.Result.NEW);
    GitRepository.doRefUpdate(jGitRepo, revWalk, ref, commitId);

    when(refUpdate.update(revWalk)).thenReturn(RefUpdate.Result.FAST_FORWARD);
    GitRepository.doRefUpdate(jGitRepo, revWalk, ref, commitId);

    when(refUpdate.update(revWalk)).thenReturn(RefUpdate.Result.LOCK_FAILURE);
    assertThatThrownBy(() -> GitRepository.doRefUpdate(jGitRepo, revWalk, ref, commitId))
            .isInstanceOf(StorageException.class);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:19,代码来源:GitRepositoryTest.java


示例4: deleteRef

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
public static void deleteRef(RefUpdate refUpdate) {
	try {
		refUpdate.setForceUpdate(true);
		RefUpdate.Result result = refUpdate.delete();
        if (result == RefUpdate.Result.LOCK_FAILURE
        		&& refUpdate.getExpectedOldObjectId() != null
        		&& !refUpdate.getExpectedOldObjectId().equals(refUpdate.getOldObjectId())) {
        	throw new ObsoleteCommitException(refUpdate.getOldObjectId());
        } else if (result != RefUpdate.Result.FAST_FORWARD && result != RefUpdate.Result.FORCED
        		&& result != RefUpdate.Result.NEW && result != RefUpdate.Result.NO_CHANGE) {
        	throw new RefUpdateException(result);
        } 
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:17,代码来源:GitUtils.java


示例5: open

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
@Transactional
@Override
public void open(PullRequest request) {
	request.setNumber(getNextNumber(request.getTargetProject()));
	dao.persist(request);
	
	RefUpdate refUpdate = GitUtils.getRefUpdate(request.getTargetProject().getRepository(), request.getBaseRef());
	refUpdate.setNewObjectId(ObjectId.fromString(request.getBaseCommitHash()));
	GitUtils.updateRef(refUpdate);
	
	refUpdate = GitUtils.getRefUpdate(request.getTargetProject().getRepository(), request.getHeadRef());
	refUpdate.setNewObjectId(ObjectId.fromString(request.getHeadCommitHash()));
	GitUtils.updateRef(refUpdate);
	
	for (PullRequestUpdate update: request.getUpdates()) {
		pullRequestUpdateManager.save(update, false);
	}
	
	for (ReviewInvitation invitation: request.getReviewInvitations())
		reviewInvitationManager.save(invitation);

	checkAsync(request);
	
	listenerRegistry.post(new PullRequestOpened(request));
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:26,代码来源:DefaultPullRequestManager.java


示例6: checkUpdate

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
private void checkUpdate(PullRequest request) {
	if (!request.getHeadCommitHash().equals(request.getSource().getObjectName())) {
		ObjectId mergeBase = GitUtils.getMergeBase(
				request.getTargetProject().getRepository(), request.getTarget().getObjectId(), 
				request.getSourceProject().getRepository(), request.getSource().getObjectId(), 
				GitUtils.branch2ref(request.getSourceBranch()));
		if (mergeBase != null) {
			PullRequestUpdate update = new PullRequestUpdate();
			update.setRequest(request);
			update.setHeadCommitHash(request.getSource().getObjectName());
			update.setMergeBaseCommitHash(mergeBase.name());
			request.addUpdate(update);
			pullRequestUpdateManager.save(update, true);
			
			RefUpdate refUpdate = GitUtils.getRefUpdate(request.getTargetProject().getRepository(), 
					request.getHeadRef());
			refUpdate.setNewObjectId(ObjectId.fromString(request.getHeadCommitHash()));
			GitUtils.updateRef(refUpdate);
		}
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:22,代码来源:DefaultPullRequestManager.java


示例7: updateMasterRecord

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
/**
 *
 * @param repo
 * @param objectId
 * @throws IOException
 */
public static void updateMasterRecord(Repository repo, ObjectId objectId) throws IOException {

    RefUpdate refUpdate = repo.updateRef(Constants.HEAD);
    refUpdate.setNewObjectId(objectId);
    final RefUpdate.Result result = refUpdate.forceUpdate();

    switch (result) {
        case NEW:
            System.out.println("New commit!\n");
            break;
        case FORCED:
            System.out.println("Forced change commit!\n");
            break;
        default: {
            System.out.println(result.name());
        }
    }
}
 
开发者ID:alexmy21,项目名称:gmds,代码行数:25,代码来源:Commands.java


示例8: tagDelete

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的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


示例9: deleteRef

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
private static void deleteRef(Repository repo, ChangeEdit edit) throws IOException {
  String refName = edit.getRefName();
  RefUpdate ru = repo.updateRef(refName, true);
  ru.setExpectedOldObjectId(edit.getEditCommit());
  ru.setForceUpdate(true);
  RefUpdate.Result result = ru.delete();
  switch (result) {
    case FORCED:
    case NEW:
    case NO_CHANGE:
      break;
    case FAST_FORWARD:
    case IO_FAILURE:
    case LOCK_FAILURE:
    case NOT_ATTEMPTED:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case RENAMED:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_OTHER_REASON:
    default:
      throw new IOException(String.format("Failed to delete ref %s: %s", refName, result));
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:ChangeEditUtil.java


示例10: updateReference

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
private void updateReference(
    Repository repository,
    String refName,
    ObjectId currentObjectId,
    ObjectId targetObjectId,
    Timestamp timestamp)
    throws IOException {
  RefUpdate ru = repository.updateRef(refName);
  ru.setExpectedOldObjectId(currentObjectId);
  ru.setNewObjectId(targetObjectId);
  ru.setRefLogIdent(getRefLogIdent(timestamp));
  ru.setRefLogMessage("inline edit (amend)", false);
  ru.setForceUpdate(true);
  try (RevWalk revWalk = new RevWalk(repository)) {
    RefUpdate.Result res = ru.update(revWalk);
    if (res != RefUpdate.Result.NEW && res != RefUpdate.Result.FORCED) {
      throw new IOException(
          "cannot update "
              + ru.getName()
              + " in "
              + repository.getDirectory()
              + ": "
              + ru.getResult());
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:ChangeEditModifier.java


示例11: call

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的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


示例12: store

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的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


示例13: deleteUserBranch

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的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


示例14: createUserBranch

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的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


示例15: create

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
public void create() throws IOException, ConfigInvalidException {
  try (Repository git = mgr.openRepository(allProjectsName)) {
    initAllProjects(git);
  } catch (RepositoryNotFoundException notFound) {
    // A repository may be missing if this project existed only to store
    // inheritable permissions. For example 'All-Projects'.
    try (Repository git = mgr.createRepository(allProjectsName)) {
      initAllProjects(git);
      RefUpdate u = git.updateRef(Constants.HEAD);
      u.link(RefNames.REFS_CONFIG);
    } catch (RepositoryNotFoundException err) {
      String name = allProjectsName.get();
      throw new IOException("Cannot create repository " + name, err);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:AllProjectsCreator.java


示例16: save

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
private void save() throws Exception {
  PersonIdent ident = new PersonIdent("A U Thor", "[email protected]");
  CommitBuilder cb = new CommitBuilder();
  cb.setAuthor(ident);
  cb.setCommitter(ident);
  RefUpdate.Result result = store.save(cb);
  switch (result) {
    case NEW:
    case FAST_FORWARD:
    case FORCED:
      break;
    case IO_FAILURE:
    case LOCK_FAILURE:
    case NOT_ATTEMPTED:
    case NO_CHANGE:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case RENAMED:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_OTHER_REASON:
    default:
      throw new AssertionError(result);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:PublicKeyCheckerTest.java


示例17: setUp

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  TestKey key1 = validKeyWithoutExpiration();
  TestKey key3 = expiredKey();
  repo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
  store = new PublicKeyStore(repo);
  store.add(key1.getPublicKeyRing());
  store.add(key3.getPublicKeyRing());

  PersonIdent ident = new PersonIdent("A U Thor", "[email protected]");
  CommitBuilder cb = new CommitBuilder();
  cb.setAuthor(ident);
  cb.setCommitter(ident);
  assertEquals(RefUpdate.Result.NEW, store.save(cb));

  signedPushConfig = new SignedPushConfig();
  signedPushConfig.setCertNonceSeed("sekret");
  signedPushConfig.setCertNonceSlopLimit(60 * 24);
  checker = newChecker(true);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:PushCertificateCheckerTest.java


示例18: updateExisting

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
@Test
public void updateExisting() throws Exception {
  TestKey key5 = validKeyWithSecondUserId();
  PGPPublicKeyRing keyRing = key5.getPublicKeyRing();
  PGPPublicKey key = keyRing.getPublicKey();
  store.add(keyRing);
  assertEquals(RefUpdate.Result.NEW, store.save(newCommitBuilder()));

  assertUserIds(
      store.get(key5.getKeyId()).iterator().next(),
      "Testuser Five <[email protected]>",
      "foo:myId");

  keyRing = PGPPublicKeyRing.removePublicKey(keyRing, key);
  key = PGPPublicKey.removeCertification(key, "foo:myId");
  keyRing = PGPPublicKeyRing.insertPublicKey(keyRing, key);
  store.add(keyRing);
  assertEquals(RefUpdate.Result.FAST_FORWARD, store.save(newCommitBuilder()));

  Iterator<PGPPublicKeyRing> keyRings = store.get(key.getKeyID()).iterator();
  keyRing = keyRings.next();
  assertFalse(keyRings.hasNext());
  assertUserIds(keyRing, "Testuser Five <[email protected]>");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:PublicKeyStoreTest.java


示例19: forcePushNotAllowed

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
@Test
public void forcePushNotAllowed() throws Exception {
  ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
  PushOneCommit push1 =
      pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
  PushOneCommit.Result r1 = push1.to("refs/heads/master");
  r1.assertOkStatus();

  // Reset HEAD to initial so the new change is a non-fast forward
  RefUpdate ru = repo().updateRef(HEAD);
  ru.setNewObjectId(initial);
  assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);

  PushOneCommit push2 =
      pushFactory.create(db, admin.getIdent(), testRepo, "change2", "b.txt", "content");
  push2.setForce(true);
  PushOneCommit.Result r2 = push2.to("refs/heads/master");
  r2.assertErrorStatus("non-fast forward");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:ForcePushIT.java


示例20: forcePushAllowed

import org.eclipse.jgit.lib.RefUpdate; //导入依赖的package包/类
@Test
public void forcePushAllowed() throws Exception {
  ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
  grant(project, "refs/*", Permission.PUSH, true);
  PushOneCommit push1 =
      pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
  PushOneCommit.Result r1 = push1.to("refs/heads/master");
  r1.assertOkStatus();

  // Reset HEAD to initial so the new change is a non-fast forward
  RefUpdate ru = repo().updateRef(HEAD);
  ru.setNewObjectId(initial);
  assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);

  PushOneCommit push2 =
      pushFactory.create(db, admin.getIdent(), testRepo, "change2", "b.txt", "content");
  push2.setForce(true);
  PushOneCommit.Result r2 = push2.to("refs/heads/master");
  r2.assertOkStatus();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:ForcePushIT.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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