Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RefRename


    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


        db.getFS());
    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

    writeReflog(db, rb, "Just a message", "refs/heads/a");
    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

    writeReflog(db, rb, "Just a message", "refs/heads/prefix/a");
    assertTrue("internal check, we have a log", new File(db.getDirectory(),
        "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

        if (!dst.startsWith(Constants.R_HEADS))
          dst = Constants.R_HEADS + dst;
        if (!Repository.isValidRefName(dst))
          throw die(MessageFormat.format(CLIText.get().notAValidRefName, dst));

        RefRename r = db.renameRef(src, dst);
        if (r.rename() != Result.RENAMED)
          throw die(MessageFormat.format(CLIText.get().cannotBeRenamed, src));

      } else if (branches.size() > 0) {
        String newHead = branches.get(0);
        String startBranch;
View Full Code Here

      if (!Repository.isValidRefName(fullNewName))
        throw new InvalidRefNameException(MessageFormat.format(JGitText
            .get().branchNameInvalid, fullNewName));

      RefRename rename = repo.renameRef(fullOldName, fullNewName);
      Result renameResult = rename.rename();

      setCallable(false);

      if (Result.RENAMED != renameResult)
        throw new JGitInternalException(MessageFormat.format(JGitText
View Full Code Here

        if (!dst.startsWith(Constants.R_HEADS))
          dst = Constants.R_HEADS + dst;
        if (!Repository.isValidRefName(dst))
          throw die(MessageFormat.format(CLIText.get().notAValidRefName, dst));

        RefRename r = db.renameRef(src, dst);
        if (r.rename() != Result.RENAMED)
          throw die(MessageFormat.format(CLIText.get().cannotBeRenamed, src));

      } else if (branches.size() > 0) {
        String newHead = branches.get(0);
        String startBranch;
View Full Code Here

    assertFalse("precondition, no log on old branchg", new File(db
        .getDirectory(), "logs/refs/heads/b").exists());
    ObjectId rb = db.resolve("refs/heads/b");
    ObjectId oldHead = db.resolve(Constants.HEAD);
    assertFalse(rb.equals(oldHead)); // assumption for this test
    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(1, db.getReflogReader("new/name").getReverseEntries().size());
    assertEquals("Branch: renamed b to new/name", db.getReflogReader("new/name")
View Full Code Here

    assertFalse("precondition for this test, branch b != HEAD", rb
        .equals(oldHead));
    writeReflog(db, rb, 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(2, db.getReflogReader("new/name").getReverseEntries().size());
    assertEquals("Branch: renamed b to new/name", db.getReflogReader("new/name")
View Full Code Here

    ObjectId oldHead = db.resolve(Constants.HEAD);
    assertTrue("internal test condition, b == HEAD", rb.equals(oldHead));
    writeReflog(db, rb, 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

TOP

Related Classes of org.eclipse.jgit.lib.RefRename

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.