import org.eclipse.jgit.api.RebaseCommand.Operation;
import org.eclipse.jgit.api.RebaseResult.Status;
import org.eclipse.jgit.api.errors.InvalidRebaseStepException;
-import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.api.errors.UnmergedPathsException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.errors.AmbiguousObjectException;
+import org.eclipse.jgit.errors.IllegalTodoFileModification;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.junit.RepositoryTestCase;
RebaseResult res2 = git.rebase().setUpstream("HEAD~2")
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.COMMENT); // delete
- // RevCommit c4
+ try {
+ // delete RevCommit c4
+ steps.get(0).setAction(Action.COMMENT);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
try {
new RebaseTodoLine("This is a invalid comment");
fail("Constructing a comment line with invalid comment string should fail, but doesn't");
- } catch (JGitInternalException e) {
+ } catch (IllegalArgumentException e) {
// expected
}
RebaseTodoLine validCommentLine = new RebaseTodoLine(
try {
actionLineToBeChanged.setComment("invalid comment");
fail("Setting a invalid comment string should fail but doesn't");
- } catch (JGitInternalException e) {
+ } catch (IllegalArgumentException e) {
assertEquals(null, actionLineToBeChanged.getComment());
}
try {
actionLineToBeChanged.setComment("invalid comment");
fail("Setting a invalid comment string should fail but doesn't");
- } catch (JGitInternalException e) {
+ } catch (IllegalArgumentException e) {
// expected
// setting comment failed, but was successfully set before,
// therefore it may not be altered since then
actionLineToBeChanged.setComment("line1 \n\r line2");
actionLineToBeChanged.setComment("\n\r");
fail("Setting a multiline comment string should fail but doesn't");
- } catch (JGitInternalException e) {
+ } catch (IllegalArgumentException e) {
// expected
}
// Try setting valid comments
RebaseResult res = git.rebase().setUpstream("HEAD~2")
.runInteractively(new InteractiveHandler() {
+
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.REWORD);
+ try {
+ steps.get(0).setAction(Action.REWORD);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
+
public String modifyCommitMessage(String commit) {
return "rewritten commit message";
}
RebaseResult res = git.rebase().setUpstream("HEAD~2")
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.EDIT);
+ try {
+ steps.get(0).setAction(Action.EDIT);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.SQUASH);
+ try {
+ steps.get(1).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.SQUASH);
- steps.get(2).setAction(Action.SQUASH);
+ try {
+ steps.get(1).setAction(Action.SQUASH);
+ steps.get(2).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.FIXUP);
- steps.get(2).setAction(Action.SQUASH);
+ try {
+ steps.get(1).setAction(Action.FIXUP);
+ steps.get(2).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.FIXUP);
+ try {
+ steps.get(1).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.FIXUP);
+ try {
+ steps.get(1).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.FIXUP);
+ try {
+ steps.get(0).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.SQUASH);
+ try {
+ steps.get(0).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.EDIT);
+ try {
+ steps.get(0).setAction(Action.EDIT);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
public void prepareSteps(List<RebaseTodoLine> steps) {
steps.remove(0);
- steps.get(0).setAction(Action.EDIT);
+ try {
+ steps.get(0).setAction(Action.EDIT);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
public void prepareSteps(List<RebaseTodoLine> steps) {
steps.remove(0);
- steps.get(0).setAction(Action.REWORD);
+ try {
+ steps.get(0).setAction(Action.REWORD);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
public void prepareSteps(List<RebaseTodoLine> steps) {
steps.remove(0);
- steps.get(0).setAction(Action.REWORD);
+ try {
+ steps.get(0).setAction(Action.REWORD);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.PICK);
- steps.remove(1);
- steps.get(1).setAction(Action.SQUASH);
+ try {
+ steps.get(0).setAction(Action.PICK);
+ steps.remove(1);
+ steps.get(1).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
result = git.rebase().runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.PICK);
- steps.remove(1);
- steps.get(1).setAction(Action.SQUASH);
+ try {
+ steps.get(0).setAction(Action.PICK);
+ steps.remove(1);
+ steps.get(1).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.PICK);
- steps.remove(1);
- steps.get(1).setAction(Action.FIXUP);
+ try {
+ steps.get(0).setAction(Action.PICK);
+ steps.remove(1);
+ steps.get(1).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
result = git.rebase().runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.PICK);
- steps.remove(1);
- steps.get(1).setAction(Action.FIXUP);
+ try {
+ steps.get(0).setAction(Action.PICK);
+ steps.remove(1);
+ steps.get(1).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.EDIT);
- steps.get(1).setAction(Action.PICK);
+ try {
+ steps.get(0).setAction(Action.EDIT);
+ steps.get(1).setAction(Action.PICK);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
--- /dev/null
+/*
+ * Copyright (C) 2013, Christian Halstrick <christian.halstrick@sap.com>
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.eclipse.jgit.errors;
+
+/**
+ * Attempt to modify a rebase-todo file in an unsupported way
+ *
+ * @since 3.2
+ */
+public class IllegalTodoFileModification extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @param msg
+ */
+ public IllegalTodoFileModification(final String msg) {
+ super(msg);
+ }
+}