Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.Repository.updateRef()


          patchSetInfoFactory.get(revWalk.parseCommit(id), ps.getId());
      change.setCurrentPatchSet(info);
      ChangeUtil.updated(change);
      db.changes().insert(Collections.singleton(change));

      final RefUpdate ru = git.updateRef(ps.getRefName());
      ru.setNewObjectId(id);
      ru.disableRefLog();
      if (ru.update(revWalk) != RefUpdate.Result.NEW) {
        throw new IOException("Failed to create ref " + ps.getRefName()
            + " in " + git.getDirectory() + ": " + ru.getResult());
View Full Code Here


      throw new NoSuchChangeException(patchSetId.getParentKey());
    }

    Repository repo = gitManager.openRepository(change.getProject());
    try {
      RefUpdate update = repo.updateRef(patch.getRefName());
      update.setForceUpdate(true);
      update.disableRefLog();
      switch (update.delete()) {
        case NEW:
        case FAST_FORWARD:
View Full Code Here

      // set the branch refs
      RevWalk revWalk = new RevWalk(db);
      try {
        // set the master branch
        RevCommit revCommit = revWalk.parseCommit(commitId);
        RefUpdate masterRef = db.updateRef(Constants.R_MASTER);
        masterRef.setNewObjectId(commitId);
        masterRef.setRefLogMessage("commit: " + revCommit.getShortMessage(), false);
        Result masterRC = masterRef.update();
        switch (masterRC) {
        case NEW:
View Full Code Here

          success = false;
        }

        if (addGitFlow) {
          // set the develop branch for git-flow
          RefUpdate developRef = db.updateRef(Constants.R_DEVELOP);
          developRef.setNewObjectId(commitId);
          developRef.setRefLogMessage("commit: " + revCommit.getShortMessage(), false);
          Result developRC = developRef.update();
          switch (developRC) {
          case NEW:
View Full Code Here

  public void oneOriginChange() throws Exception {
    RevCommit commit1 = add("test.txt", "content");
    File repo2 = initRepo();
    RevCommit commit2 = add(repo2, "test2.txt", "content2.txt");
    Repository repo = new FileRepository(testRepo);
    RefUpdate originMaster = repo.updateRef(Constants.R_REMOTES
        + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER);
    originMaster.setNewObjectId(commit1);
    originMaster.forceUpdate();
    RemoteConfig config = new RemoteConfig(repo.getConfig(),
        Constants.DEFAULT_REMOTE_NAME);
View Full Code Here

  }

  @Test(expected = NoHeadException.class)
  public void testPullEmptyRepository() throws Exception {
    Repository empty = createWorkRepository();
    RefUpdate delete = empty.updateRef(Constants.HEAD, true);
    delete.setForceUpdate(true);
    delete.delete();
    Git.wrap(empty).pull().call();
  }
View Full Code Here

    initialCommit = remoteGit.commit().setMessage("Initial commit").call();
    writeTrashFile("Test.txt", "Some change");
    remoteGit.add().addFilepattern("Test.txt").call();
    secondCommit = remoteGit.commit().setMessage("Second commit").call();
    // create a master branch
    RefUpdate rup = remoteRepository.updateRef("refs/heads/master");
    rup.setNewObjectId(initialCommit.getId());
    rup.forceUpdate();

    Repository localRepository = createWorkRepository();
    Git localGit = new Git(localRepository);
View Full Code Here

    rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
    rc.update(config);
    config.save();
    FetchResult res = localGit.fetch().setRemote("origin").call();
    assertFalse(res.getTrackingRefUpdates().isEmpty());
    rup = localRepository.updateRef("refs/heads/master");
    rup.setNewObjectId(initialCommit.getId());
    rup.forceUpdate();
    rup = localRepository.updateRef(Constants.HEAD);
    rup.link("refs/heads/master");
    rup.setNewObjectId(initialCommit.getId());
View Full Code Here

    FetchResult res = localGit.fetch().setRemote("origin").call();
    assertFalse(res.getTrackingRefUpdates().isEmpty());
    rup = localRepository.updateRef("refs/heads/master");
    rup.setNewObjectId(initialCommit.getId());
    rup.forceUpdate();
    rup = localRepository.updateRef(Constants.HEAD);
    rup.link("refs/heads/master");
    rup.setNewObjectId(initialCommit.getId());
    rup.update();
    return localGit;
  }
View Full Code Here

            DirCacheCheckout co = new DirCacheCheckout(
                submoduleRepo, submoduleRepo.lockDirCache(),
                commit.getTree());
            co.setFailOnConflict(true);
            co.checkout();
            RefUpdate refUpdate = submoduleRepo.updateRef(
                Constants.HEAD, true);
            refUpdate.setNewObjectId(commit);
            refUpdate.forceUpdate();
          }
        } finally {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.