Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RefRename


      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);

      boolean ok = Result.RENAMED == renameResult;
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

      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);

      boolean ok = Result.RENAMED == renameResult;
View Full Code Here

        oldRef = ref.reference;
      }
    }
    if (oldRef != null) {
      // rename old ref to refs/meta/gitblit/tickets
      RefRename cmd;
      try {
        cmd = db.renameRef(oldRef.getName(), BRANCH);
        cmd.setRefLogIdent(new PersonIdent("Gitblit", "gitblit@localhost"));
        cmd.setRefLogMessage("renamed " + oldRef.getName() + " => " + BRANCH);
        Result res = cmd.rename();
        switch (res) {
        case RENAMED:
          log.info(db.getDirectory() + " " + cmd.getRefLogMessage());
          return getTicketsBranch(db);
        default:
          log.error("failed to rename " + oldRef.getName() + " => " + BRANCH + " (" + res.name() + ")");
        }
      } catch (IOException e) {
View Full Code Here

        oldRef = ref.reference;
      }
    }
    if (oldRef != null) {
      // rename old ref to refs/meta/gitblit/reflog
      RefRename cmd;
      try {
        cmd = repository.renameRef(oldRef.getName(), GB_REFLOG);
        cmd.setRefLogIdent(new PersonIdent("Gitblit", "gitblit@localhost"));
        cmd.setRefLogMessage("renamed " + oldRef.getName() + " => " + GB_REFLOG);
        Result res = cmd.rename();
        switch (res) {
        case RENAMED:
          LOGGER.info(repository.getDirectory() + " " + cmd.getRefLogMessage());
          return getRefLogBranch(repository);
        default:
          LOGGER.error("failed to rename " + oldRef.getName() + " => " + GB_REFLOG + " (" + res.name() + ")");
        }
      } catch (IOException e) {
View Full Code Here

        oldRef = ref.reference;
      }
    }
    if (oldRef != null) {
      // rename old ref to refs/meta/gitblit/tickets
      RefRename cmd;
      try {
        cmd = db.renameRef(oldRef.getName(), BRANCH);
        cmd.setRefLogIdent(new PersonIdent("Gitblit", "gitblit@localhost"));
        cmd.setRefLogMessage("renamed " + oldRef.getName() + " => " + BRANCH);
        Result res = cmd.rename();
        switch (res) {
        case RENAMED:
          log.info(db.getDirectory() + " " + cmd.getRefLogMessage());
          return getTicketsBranch(db);
        default:
          log.error("failed to rename " + oldRef.getName() + " => " + BRANCH + " (" + res.name() + ")");
        }
      } catch (IOException e) {
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, "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);
    assertEquals("internal test condition, b == HEAD", oldHead, rb);
    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

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.