Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2011-03-17 14:14:15 -0400
committerJens Baumgart2011-03-17 14:14:15 -0400
commit3a1995dbcc1fb131b2b8b5dfb54b58788a0c7df1 (patch)
treed8769ea0abdd440c9fa35409a4633bcc48734806 /org.eclipse.egit.core.test
parent24c22b3ab2dccb14034b800c4ff53fbce501f1ed (diff)
downloadegit-3a1995dbcc1fb131b2b8b5dfb54b58788a0c7df1.tar.gz
egit-3a1995dbcc1fb131b2b8b5dfb54b58788a0c7df1.tar.xz
egit-3a1995dbcc1fb131b2b8b5dfb54b58788a0c7df1.zip
CommitOperation: use JGit Commit Command
The usages of the deprecated GitIndex class were replaced by using the JGit CommitCommand. Depends on JGit change http://egit.eclipse.org/r/#change,2760 Change-Id: Ibd0e883bb6c82c42d1b3bd08743dd7d050e95291 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com> Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
index d45b9ee06..be69527e5 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
@@ -12,6 +12,7 @@ package org.eclipse.egit.core.test.op;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
import java.util.ArrayList;
@@ -21,6 +22,8 @@ import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.egit.core.op.AddToIndexOperation;
import org.eclipse.egit.core.op.CommitOperation;
import org.eclipse.egit.core.test.GitTestCase;
@@ -75,13 +78,28 @@ public class CommitOperationTest extends GitTestCase {
testUtils.addFileToProject(project.getProject(), "zar/b.txt", "some text");
resources.add(project.getProject().getFolder("zar"));
new AddToIndexOperation(resources).execute(null);
- project.getProject().getFile("zar/b.txt").delete(true, null);
+ IFile zarFile = project.getProject().getFile("zar/b.txt");
+ IPath zarFilePath = zarFile.getLocation();
+ // delete file and refresh. Deleting using the resource would trigger
+ // GitMoveDeleteHook which removes the file from the index
+ assertTrue("could not delete file " + zarFilePath.toOSString(),
+ zarFilePath.toFile().delete());
+ zarFile.refreshLocal(0, null);
+
assertTrue(!project.getProject().getFile("zar/b.txt").exists());
IFile[] filesToCommit = new IFile[] { project.getProject().getFile("zar/b.txt") };
commitOperation = new CommitOperation(filesToCommit, Arrays.asList(filesToCommit), null, TestUtils.AUTHOR, TestUtils.COMMITTER, "first commit");
commitOperation.setRepos(new Repository[] {repository});
- commitOperation.execute(null);
+ try {
+ commitOperation.execute(null);
+ // TODO this is very ugly. CommitCommand should be extended
+ // not to throw an JGitInternalException in case of an empty
+ // commit
+ fail("expected CoreException");
+ } catch (CoreException e) {
+ assertEquals("No changes", e.getCause().getMessage());
+ }
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(repository.resolve("HEAD^{tree}"));

Back to the top