Examples of RebaseTodoLine


Examples of org.eclipse.jgit.lib.RebaseTodoLine

    RevCommit c4 = commitFile("file2", "more change", "master");

    RebaseResult res = git.rebase().setUpstream("HEAD~2")
        .runInteractively(new InteractiveHandler() {
          public void prepareSteps(List<RebaseTodoLine> steps) {
            steps.add(0, new RebaseTodoLine(
                "# Comment that should not be processed"));
          }

          public String modifyCommitMessage(String commit) {
            fail("modifyCommitMessage() was not expected to be called");
View Full Code Here

Examples of org.eclipse.jgit.lib.RebaseTodoLine

    write(getTodoFile(), todo);

    List<RebaseTodoLine> steps = db.readRebaseTodo(GIT_REBASE_TODO, true);
    assertEquals(3, steps.size());

    RebaseTodoLine firstLine = steps.get(0);

    assertEquals("1111111", firstLine.getCommit().name());
    assertEquals("Valid line commented out with space",
        firstLine.getShortMessage());
    assertEquals("comment", firstLine.getAction().toToken());

    try {
      firstLine.setAction(Action.PICK);
      assertEquals("1111111", firstLine.getCommit().name());
      assertEquals("pick", firstLine.getAction().toToken());
    } catch (Exception e) {
      fail("Valid parsable RebaseTodoLine that has been commented out should allow to change the action, but failed");
    }

    assertEquals("2222222", steps.get(1).getCommit().name());
View Full Code Here

Examples of org.eclipse.jgit.lib.RebaseTodoLine

  @SuppressWarnings("unused")
  @Test
  public void testRebaseTodoLineSetComment() throws Exception {
    try {
      new RebaseTodoLine("This is a invalid comment");
      fail("Constructing a comment line with invalid comment string should fail, but doesn't");
    } catch (IllegalArgumentException e) {
      // expected
    }
    RebaseTodoLine validCommentLine = new RebaseTodoLine(
        "# This is a comment");
    assertEquals(Action.COMMENT, validCommentLine.getAction());
    assertEquals("# This is a comment", validCommentLine.getComment());

    RebaseTodoLine actionLineToBeChanged = new RebaseTodoLine(Action.EDIT,
        AbbreviatedObjectId.fromString("1111111"), "short Message");
    assertEquals(null, actionLineToBeChanged.getComment());

    try {
      actionLineToBeChanged.setComment("invalid comment");
      fail("Setting a invalid comment string should fail but doesn't");
    } catch (IllegalArgumentException e) {
      assertEquals(null, actionLineToBeChanged.getComment());
    }

    actionLineToBeChanged.setComment("# valid comment");
    assertEquals("# valid comment", actionLineToBeChanged.getComment());
    try {
      actionLineToBeChanged.setComment("invalid comment");
      fail("Setting a invalid comment string should fail but doesn't");
    } catch (IllegalArgumentException e) {
      // expected
      // setting comment failed, but was successfully set before,
      // therefore it may not be altered since then
      assertEquals("# valid comment", actionLineToBeChanged.getComment());
    }
    try {
      actionLineToBeChanged.setComment("# line1 \n line2");
      actionLineToBeChanged.setComment("line1 \n line2");
      actionLineToBeChanged.setComment("\n");
      actionLineToBeChanged.setComment("# line1 \r line2");
      actionLineToBeChanged.setComment("line1 \r line2");
      actionLineToBeChanged.setComment("\r");
      actionLineToBeChanged.setComment("# line1 \n\r line2");
      actionLineToBeChanged.setComment("line1 \n\r line2");
      actionLineToBeChanged.setComment("\n\r");
      fail("Setting a multiline comment string should fail but doesn't");
    } catch (IllegalArgumentException e) {
      // expected
    }
    // Try setting valid comments
    actionLineToBeChanged.setComment("# valid comment");
    assertEquals("# valid comment", actionLineToBeChanged.getComment());

    actionLineToBeChanged.setComment("# \t \t valid comment");
    assertEquals("# \t \t valid comment",
        actionLineToBeChanged.getComment());

    actionLineToBeChanged.setComment("#       ");
    assertEquals("#       ", actionLineToBeChanged.getComment());

    actionLineToBeChanged.setComment("");
    assertEquals("", actionLineToBeChanged.getComment());

    actionLineToBeChanged.setComment("  ");
    assertEquals("  ", actionLineToBeChanged.getComment());

    actionLineToBeChanged.setComment("\t\t");
    assertEquals("\t\t", actionLineToBeChanged.getComment());

    actionLineToBeChanged.setComment(null);
    assertEquals(null, actionLineToBeChanged.getComment());
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.RebaseTodoLine

      if (operation == Operation.CONTINUE) {
        newHead = continueRebase();
        List<RebaseTodoLine> doneLines = repo.readRebaseTodo(
            rebaseState.getPath(DONE), true);
        RebaseTodoLine step = doneLines.get(doneLines.size() - 1);
        if (newHead != null
            && step.getAction() != Action.PICK) {
          RebaseTodoLine newStep = new RebaseTodoLine(
              step.getAction(),
              AbbreviatedObjectId.fromObjectId(newHead),
              step.getShortMessage());
          RebaseResult result = processStep(newStep, false);
          if (result != null)
            return result;
        }
        File amendFile = rebaseState.getFile(AMEND);
        boolean amendExists = amendFile.exists();
        if (amendExists) {
          FileUtils.delete(amendFile);
        }
        if (newHead == null && !amendExists) {
          // continueRebase() returns null only if no commit was
          // neccessary. This means that no changes where left over
          // after resolving all conflicts. In this case, cgit stops
          // and displays a nice message to the user, telling him to
          // either do changes or skip the commit instead of continue.
          return RebaseResult.NOTHING_TO_COMMIT_RESULT;
        }
      }

      if (operation == Operation.SKIP)
        newHead = checkoutCurrentHead();

      List<RebaseTodoLine> steps = repo.readRebaseTodo(
          rebaseState.getPath(GIT_REBASE_TODO), false);
      if (steps.size() == 0) {
        return finishRebase(walk.parseCommit(repo.resolve(Constants.HEAD)), false);
      }
      if (isInteractive()) {
        interactiveHandler.prepareSteps(steps);
        repo.writeRebaseTodoFile(rebaseState.getPath(GIT_REBASE_TODO),
            steps, false);
      }
      checkSteps(steps);
      for (int i = 0; i < steps.size(); i++) {
        RebaseTodoLine step = steps.get(i);
        popSteps(1);
        RebaseResult result = processStep(step, true);
        if (result != null) {
          return result;
        }
View Full Code Here

Examples of org.eclipse.jgit.lib.RebaseTodoLine

      //$FALL-THROUGH$
    case FIXUP:
      resetSoftToParent();
      List<RebaseTodoLine> steps = repo.readRebaseTodo(
          rebaseState.getPath(GIT_REBASE_TODO), false);
      RebaseTodoLine nextStep = steps.size() > 0 ? steps.get(0) : null;
      File messageFixupFile = rebaseState.getFile(MESSAGE_FIXUP);
      File messageSquashFile = rebaseState.getFile(MESSAGE_SQUASH);
      if (isSquash && messageFixupFile.exists())
        messageFixupFile.delete();
      newHead = doSquashFixup(isSquash, commitToPick, nextStep,
View Full Code Here

Examples of org.eclipse.jgit.lib.RebaseTodoLine

    rebaseState.createFile(ONTO_NAME, upstreamCommitName);
    rebaseState.createFile(INTERACTIVE, ""); //$NON-NLS-1$
    rebaseState.createFile(QUIET, ""); //$NON-NLS-1$

    ArrayList<RebaseTodoLine> toDoSteps = new ArrayList<RebaseTodoLine>();
    toDoSteps.add(new RebaseTodoLine("# Created by EGit: rebasing " + headId.name() //$NON-NLS-1$
            + " onto " + upstreamCommit.name())); //$NON-NLS-1$
    // determine the commits to be applied
    List<RevCommit> cherryPickList = calculatePickList(headCommit);
    ObjectReader reader = walk.getObjectReader();
    for (RevCommit commit : cherryPickList)
      toDoSteps.add(new RebaseTodoLine(Action.PICK, reader
          .abbreviate(commit), commit.getShortMessage()));
    repo.writeRebaseTodoFile(rebaseState.getPath(GIT_REBASE_TODO),
        toDoSteps, false);

    monitor.endTask();
View Full Code Here

Examples of org.eclipse.jgit.lib.RebaseTodoLine

            List<RevCommit> stepCommits = new ArrayList<RevCommit>(
                commits);
            Collections.reverse(stepCommits);

            for (RevCommit commit : stepCommits) {
              RebaseTodoLine step = new RebaseTodoLine(
                  RebaseTodoLine.Action.PICK,
                  commit.abbreviate(7), ""); //$NON-NLS-1$
              steps.add(step);
            }
          }
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.