Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2010-08-09 11:46:18 -0400
committerChris Aniszczyk2010-08-11 16:25:46 -0400
commit0261f7af1225181e78aa6932044d7fb336cc60c3 (patch)
treef6cae2b8ebc90798a7cd81c2fd59805b2b2de691 /org.eclipse.egit.core.test
parent0bfb7bef58c1999f93d6473453ab5b8fc89c93f2 (diff)
downloadegit-0261f7af1225181e78aa6932044d7fb336cc60c3.tar.gz
egit-0261f7af1225181e78aa6932044d7fb336cc60c3.tar.xz
egit-0261f7af1225181e78aa6932044d7fb336cc60c3.zip
Update of GitSynchronizeData API
In Git synchronization we always operate on commit level changes therefore source and destination points should be always RevCommit objects. In case of synchronizing tags we should map given tag with proper RevCommit object. Instead of doing this multiple times on different levels I've add this resolution to GitSynchronizeData constructor. Change-Id: I6476b4940783d4b719d08d9c0c5bb3060b1ee412 Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java22
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java36
2 files changed, 37 insertions, 21 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
index 904333aa0..80f0fd1f5 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
@@ -15,6 +15,7 @@ import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.eclipse.jgit.lib.Constants.HEAD;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -33,6 +34,7 @@ import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet;
import org.eclipse.egit.core.test.GitTestCase;
import org.eclipse.egit.core.test.TestRepository;
+import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -57,6 +59,10 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
testRepo = new TestRepository(gitDir);
testRepo.connect(iProject);
repo = RepositoryMapping.getMapping(iProject).getRepository();
+
+ // make initial commit
+ new Git(repo).commit().setAuthor("JUnit", "junit@jgit.org")
+ .setMessage("Initall commit").call();
}
@After
@@ -172,11 +178,11 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
+ "keep");
RevCommit commit = testRepo.addAndCommit(iProject, file,
"initial commit");
- String path = Repository.stripWorkDir(repo.getWorkTree(), file.getParentFile());
+ String path = Repository.stripWorkDir(repo.getWorkTree(), file);
IPath iPath = new Path(File.separator + path);
IContainer local = createMock(IContainer.class);
- expect(local.exists()).andReturn(true).anyTimes();
+ expect(local.exists()).andReturn(true);
expect(local.getFullPath()).andReturn(iPath).anyTimes();
replay(local);
@@ -201,7 +207,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
// when
byte[] shortContent = "short content".getBytes();
byte[] longContent = "very long long content".getBytes();
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -243,7 +249,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
byte[] localContent = "very long long content".getBytes();
// this typo should be here
byte[] remoteContent = "very long lonk content".getBytes();
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -287,7 +293,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
byte[] remoteContent = new byte[8192];
Arrays.fill(remoteContent, (byte) 'a');
remoteContent[8101] = 'b';
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -335,7 +341,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
Arrays.fill(localContent, (byte) 'a');
byte[] remoteContent = new byte[8200];
Arrays.fill(remoteContent, (byte) 'a');
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -376,7 +382,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
// when
byte[] localContent = "very long long content".getBytes();
byte[] remoteContent = "very long long content".getBytes();
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -420,7 +426,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
Arrays.fill(localContent, (byte) 'a');
byte[] remoteContent = new byte[8192];
Arrays.fill(remoteContent, (byte) 'a');
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
index 073117a80..3ca306c1b 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
@@ -8,6 +8,8 @@
*******************************************************************************/
package org.eclipse.egit.core.synchronize;
+import static org.eclipse.jgit.lib.Constants.HEAD;
+import static org.eclipse.jgit.lib.Constants.MASTER;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -16,7 +18,6 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
@@ -33,6 +34,7 @@ import org.eclipse.egit.core.test.TestProject;
import org.eclipse.egit.core.test.TestRepository;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.team.core.variants.IResourceVariant;
@@ -72,12 +74,14 @@ public class GitResourceVariantTreeTest extends GitTestCase {
* given repository. In this case there is only one project associated with
* this repository therefore only one root should be returned.
*
- * @throws IOException
+ * @throws Exception
*/
@Test
- public void shouldReturnOneRoot() throws IOException {
+ public void shouldReturnOneRoot() throws Exception {
// when
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", false);
+ new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -105,7 +109,9 @@ public class GitResourceVariantTreeTest extends GitTestCase {
IProject secondIProject = secondProject.project;
// add connect project with repository
new ConnectProviderOperation(secondIProject, gitDir).execute(null);
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", false);
+ new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -130,8 +136,10 @@ public class GitResourceVariantTreeTest extends GitTestCase {
@Test
public void shouldReturnNullResourceVariant() throws Exception {
// when
- GitSynchronizeData data = new GitSynchronizeData(repo, Constants.HEAD,
- Constants.MASTER, false);
+ new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
+ false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -153,8 +161,10 @@ public class GitResourceVariantTreeTest extends GitTestCase {
IPackageFragment iPackage = project.createPackage("org.egit.test");
IType mainJava = project.createType(iPackage, "Main.java",
"class Main {}");
- GitSynchronizeData data = new GitSynchronizeData(repo, Constants.HEAD,
- Constants.MASTER, false);
+ new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
+ false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -179,8 +189,8 @@ public class GitResourceVariantTreeTest extends GitTestCase {
testRepo.appendContentAndCommit(iProject, file, "class Main {}",
"initial commit");
IFile mainJava = testRepo.getIFile(iProject, file);
- GitSynchronizeData data = new GitSynchronizeData(repo, Constants.HEAD,
- Constants.MASTER, false);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
+ false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -221,8 +231,8 @@ public class GitResourceVariantTreeTest extends GitTestCase {
Constants.R_HEADS + "test");
testRepo.appendContentAndCommit(iProject, file, "// test",
"first commit");
- GitSynchronizeData data = new GitSynchronizeData(repo, Constants.HEAD,
- Constants.MASTER, false);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
+ false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given

Back to the top