Package org.eclipse.jgit.lib.RefUpdate

Examples of org.eclipse.jgit.lib.RefUpdate.Result


    writeReflog(db, rb, "Just a message", "refs/heads/b");
    assertTrue("log on old branch", new File(db.getDirectory(),
        "logs/refs/heads/b").exists());
    RefRename renameRef = db.renameRef("refs/heads/b",
        "refs/heads/new/name");
    Result result = renameRef.rename();
    assertEquals(Result.RENAMED, result);
    assertEquals(rb, db.resolve("refs/heads/new/name"));
    assertNull(db.resolve("refs/heads/b"));
    assertEquals("Branch: renamed b to new/name", db.getReflogReader(
        "new/name").getLastEntry().getComment());
View Full Code Here


    ObjectId rb2 = db.resolve("refs/heads/b~1");
    assertEquals(Ref.Storage.PACKED, db.getRef("refs/heads/b").getStorage());
    RefUpdate updateRef = db.updateRef("refs/heads/b");
    updateRef.setNewObjectId(rb2);
    updateRef.setForceUpdate(true);
    Result update = updateRef.update();
    assertEquals("internal check new ref is loose", Result.FORCED, update);
    assertEquals(Ref.Storage.LOOSE, db.getRef("refs/heads/b").getStorage());
    writeReflog(db, rb, "Just a message", "refs/heads/b");
    assertTrue("log on old branch", new File(db.getDirectory(),
        "logs/refs/heads/b").exists());
    RefRename renameRef = db.renameRef("refs/heads/b",
        "refs/heads/new/name");
    Result result = renameRef.rename();
    assertEquals(Result.RENAMED, result);
    assertEquals(rb2, db.resolve("refs/heads/new/name"));
    assertNull(db.resolve("refs/heads/b"));
    assertEquals("Branch: renamed b to new/name", db.getReflogReader(
        "new/name").getLastEntry().getComment());
View Full Code Here

    try {
      assertTrue(lockFile.lock());

      // Now this is our test
      RefRename renameRef = db.renameRef(fromName, toName);
      Result result = renameRef.rename();
      assertEquals(Result.LOCK_FAILURE, result);

      // Check that the involved refs are the same despite the failure
      assertExists(false, toName);
      if (!toLock.equals(toName))
View Full Code Here

    assertTrue("internal check, we have a log", new File(db.getDirectory(),
        "logs/refs/heads/a").exists());

    // Now this is our test
    RefRename renameRef = db.renameRef("refs/heads/a", "refs/heads/a/b");
    Result result = renameRef.rename();
    assertEquals(Result.RENAMED, result);
    assertNull(db.resolve("refs/heads/a"));
    assertEquals(rb, db.resolve("refs/heads/a/b"));
    assertEquals(3, db.getReflogReader("a/b").getReverseEntries().size());
    assertEquals("Branch: renamed a to a/b", db.getReflogReader("a/b")
View Full Code Here

        "logs/refs/heads/prefix/a").exists());

    // Now this is our test
    RefRename renameRef = db.renameRef("refs/heads/prefix/a",
        "refs/heads/prefix");
    Result result = renameRef.rename();
    assertEquals(Result.RENAMED, result);

    assertNull(db.resolve("refs/heads/prefix/a"));
    assertEquals(rb, db.resolve("refs/heads/prefix"));
    assertEquals(3, db.getReflogReader("prefix").getReverseEntries().size());
View Full Code Here

                      JGitText.get().cannotDeleteCheckedOutBranch,
                      branchName));
        RefUpdate update = repo.updateRef(fullName);
        update.setRefLogMessage("branch deleted", false); //$NON-NLS-1$
        update.setForceUpdate(true);
        Result deleteResult = update.delete();

        boolean ok = true;
        switch (deleteResult) {
        case IO_FAILURE:
        case LOCK_FAILURE:
        case REJECTED:
          ok = false;
          break;
        default:
          break;
        }

        if (ok) {
          result.add(fullName);
          if (fullName.startsWith(Constants.R_HEADS)) {
            String shortenedName = fullName
                .substring(Constants.R_HEADS.length());
            // remove upstream configuration if any
            final StoredConfig cfg = repo.getConfig();
            cfg.unsetSection(
                ConfigConstants.CONFIG_BRANCH_SECTION,
                shortenedName);
            cfg.save();
          }
        } else
          throw new JGitInternalException(MessageFormat.format(
              JGitText.get().deleteBranchUnexpectedResult,
              deleteResult.name()));
      }
      return result;
    } catch (IOException ioe) {
      throw new JGitInternalException(ioe.getMessage(), ioe);
    }
View Full Code Here

    String refName = Constants.R_TAGS + tagName;
    RefUpdate tagRef = repo.updateRef(refName);
    tagRef.setNewObjectId(tagId);
    tagRef.setForceUpdate(forceUpdate);
    tagRef.setRefLogMessage("tagged " + name, false); //$NON-NLS-1$
    Result updateResult = tagRef.update(revWalk);
    switch (updateResult) {
    case NEW:
    case FORCED:
      return repo.getRef(refName);
    case LOCK_FAILURE:
View Full Code Here

          throw die(MessageFormat.format(CLIText.get().branchAlreadyExists, newHead));
        RefUpdate updateRef = db.updateRef(newRefName);
        updateRef.setNewObjectId(startAt);
        updateRef.setForceUpdate(createForce);
        updateRef.setRefLogMessage(MessageFormat.format(CLIText.get().branchCreatedFrom, startBranch), false);
        Result update = updateRef.update();
        if (update == Result.REJECTED)
          throw die(MessageFormat.format(CLIText.get().couldNotCreateBranch, newHead, update.toString()));
      } else {
        if (verbose)
          rw = new RevWalk(db);
        list();
      }
View Full Code Here

      RefUpdate update = db.updateRef((remote ? Constants.R_REMOTES
          : Constants.R_HEADS)
          + branch);
      update.setNewObjectId(head);
      update.setForceUpdate(force || remote);
      Result result = update.delete();
      if (result == Result.REJECTED) {
        throw die(MessageFormat.format(CLIText.get().branchIsNotAnAncestorOfYourCurrentHEAD, branch));
      } else if (result == Result.NEW)
        throw die(MessageFormat.format(CLIText.get().branchNotFound, branch));
      if (remote)
View Full Code Here

        inserter.flush();

        RefUpdate ru = repo.updateRef(Constants.HEAD);
        ru.setNewObjectId(commitId);
        ru.setExpectedOldObjectId(headId != null ? headId : ObjectId.zeroId());
        Result rc = ru.update(rw);

        switch (rc) {
          case NEW:
          case FORCED:
          case FAST_FORWARD:
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.RefUpdate.Result

Copyright © 2018 www.massapicom. 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.