diff --git a/org.gitective.core/pom.xml b/org.gitective.core/pom.xml
index e378232..e5627f9 100644
--- a/org.gitective.core/pom.xml
+++ b/org.gitective.core/pom.xml
@@ -9,7 +9,7 @@
org.gitective
gitective-core
- 0.9.10-SNAPSHOT
+ 0.9.10
gitective core
gitective core library
http://gitective.org
@@ -190,7 +190,7 @@
org.eclipse.jgit
org.eclipse.jgit
- 2.0.0.201206130900-r
+ 3.0.0.201306101825-r
junit
diff --git a/org.gitective.core/src/main/java/org/gitective/core/RepositoryService.java b/org.gitective.core/src/main/java/org/gitective/core/RepositoryService.java
index 67043d9..d7bd3db 100644
--- a/org.gitective.core/src/main/java/org/gitective/core/RepositoryService.java
+++ b/org.gitective.core/src/main/java/org/gitective/core/RepositoryService.java
@@ -27,8 +27,9 @@
import java.util.Collection;
import java.util.List;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
/**
* Base service class for working with one or more {@link Repository} instances.
@@ -81,8 +82,12 @@ public RepositoryService(final File... gitDirs) {
final int length = gitDirs.length;
repositories = new Repository[length];
try {
- for (int i = 0; i < length; i++)
- repositories[i] = new FileRepository(gitDirs[i]);
+ for (int i = 0; i < length; i++) {
+ repositories[i] = new FileRepositoryBuilder()
+ .setGitDir(gitDirs[i])
+ .readEnvironment()
+ .build();
+ }
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
@@ -126,9 +131,9 @@ public RepositoryService(final Collection> repositories) {
try {
for (Object repo : repositories)
if (repo instanceof String)
- created.add(new FileRepository((String) repo));
+ created.add(new FileRepositoryBuilder().setGitDir(new File((String)repo)).readEnvironment().build());
else if (repo instanceof File)
- created.add(new FileRepository((File) repo));
+ created.add(new FileRepositoryBuilder().setGitDir((File)repo).readEnvironment().build());
else if (repo instanceof Repository)
created.add((Repository) repo);
} catch (IOException e) {
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/BadRepository.java b/org.gitective.core/src/test/java/org/gitective/tests/BadRepository.java
index d18d16e..868a046 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/BadRepository.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/BadRepository.java
@@ -24,9 +24,9 @@
import java.io.File;
import java.io.IOException;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.lib.BaseRepositoryBuilder;
import org.eclipse.jgit.lib.RefDatabase;
-import org.eclipse.jgit.storage.file.FileRepository;
/**
* Repository that has a bad ref database
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/BlobUtilsTest.java b/org.gitective.core/src/test/java/org/gitective/tests/BlobUtilsTest.java
index f71a461..63c6a77 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/BlobUtilsTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/BlobUtilsTest.java
@@ -30,18 +30,11 @@
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.Edit;
import org.eclipse.jgit.diff.Edit.Type;
-import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.LargeObjectException;
-import org.eclipse.jgit.errors.MissingObjectException;
-import org.eclipse.jgit.lib.AbbreviatedObjectId;
-import org.eclipse.jgit.lib.AnyObjectId;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.ObjectLoader;
-import org.eclipse.jgit.lib.ObjectStream;
-import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
+import org.eclipse.jgit.lib.*;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.gitective.core.BlobUtils;
import org.gitective.core.CommitFinder;
import org.gitective.core.GitException;
@@ -77,7 +70,7 @@ public void getContentNullRepository() {
*/
@Test(expected = IllegalArgumentException.class)
public void getContentNullObjectId() throws Exception {
- BlobUtils.getContent(new FileRepository(testRepo), null);
+ BlobUtils.getContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), null);
}
/**
@@ -87,7 +80,7 @@ public void getContentNullObjectId() throws Exception {
*/
@Test(expected = GitException.class)
public void badObjectLoader() throws Exception {
- BlobUtils.getContent(new FileRepository(testRepo), ObjectId.zeroId());
+ BlobUtils.getContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId());
}
/**
@@ -114,13 +107,12 @@ public boolean include(RevCommit commit, Collection diffs) {
Repository repo = new FileRepository(testRepo) {
public ObjectLoader open(AnyObjectId objectId, int typeHint)
- throws MissingObjectException,
- IncorrectObjectTypeException, IOException {
+ throws IOException {
final ObjectLoader loader = super.open(objectId, typeHint);
return new ObjectLoader() {
public ObjectStream openStream()
- throws MissingObjectException, IOException {
+ throws IOException {
return loader.openStream();
}
@@ -164,7 +156,7 @@ public boolean include(RevCommit commit, Collection diffs) {
};
new CommitFinder(testRepo).setFilter(filter).find();
assertEquals(2, ids.size());
- Collection diffs = BlobUtils.diff(new FileRepository(testRepo),
+ Collection diffs = BlobUtils.diff(new FileRepositoryBuilder().setGitDir(testRepo).build(),
ids.get(0).toObjectId(), ids.get(1).toObjectId());
assertNotNull(diffs);
assertEquals(1, diffs.size());
@@ -178,7 +170,7 @@ public boolean include(RevCommit commit, Collection diffs) {
*/
@Test
public void diffWithZeroObjectIds() throws IOException {
- Collection edits = BlobUtils.diff(new FileRepository(testRepo),
+ Collection edits = BlobUtils.diff(new FileRepositoryBuilder().setGitDir(testRepo).build(),
ObjectId.zeroId(), ObjectId.zeroId());
assertNotNull(edits);
assertTrue(edits.isEmpty());
@@ -204,7 +196,7 @@ public boolean include(RevCommit commit, Collection diffs) {
};
new CommitFinder(testRepo).setFilter(filter).find();
assertEquals(1, ids.size());
- Collection diffs = BlobUtils.diff(new FileRepository(testRepo),
+ Collection diffs = BlobUtils.diff(new FileRepositoryBuilder().setGitDir(testRepo).build(),
ids.get(0).toObjectId(), ObjectId.zeroId());
assertNotNull(diffs);
assertEquals(1, diffs.size());
@@ -231,7 +223,7 @@ public boolean include(RevCommit commit, Collection diffs) {
};
new CommitFinder(testRepo).setFilter(filter).find();
assertEquals(1, ids.size());
- Collection diffs = BlobUtils.diff(new FileRepository(testRepo),
+ Collection diffs = BlobUtils.diff(new FileRepositoryBuilder().setGitDir(testRepo).build(),
ids.get(0).toObjectId(), ObjectId.zeroId());
assertNotNull(diffs);
assertTrue(diffs.isEmpty());
@@ -257,7 +249,7 @@ public boolean include(RevCommit commit, Collection diffs) {
};
new CommitFinder(testRepo).setFilter(filter).find();
assertEquals(1, ids.size());
- Collection diffs = BlobUtils.diff(new FileRepository(testRepo),
+ Collection diffs = BlobUtils.diff(new FileRepositoryBuilder().setGitDir(testRepo).build(),
ObjectId.zeroId(), ids.get(0).toObjectId());
assertNotNull(diffs);
assertTrue(diffs.isEmpty());
@@ -278,7 +270,7 @@ public void diffWithNullRepo() {
*/
@Test(expected = IllegalArgumentException.class)
public void diffWithNullObjectId1() throws IOException {
- BlobUtils.diff(new FileRepository(testRepo), null, ObjectId.zeroId());
+ BlobUtils.diff(new FileRepositoryBuilder().setGitDir(testRepo).build(), null, ObjectId.zeroId());
}
/**
@@ -288,7 +280,7 @@ public void diffWithNullObjectId1() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void diffWithNullObjectId2() throws IOException {
- BlobUtils.diff(new FileRepository(testRepo), ObjectId.zeroId(), null);
+ BlobUtils.diff(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId(), null);
}
/**
@@ -298,7 +290,7 @@ public void diffWithNullObjectId2() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void diffWithNullComparator() throws IOException {
- BlobUtils.diff(new FileRepository(testRepo), ObjectId.zeroId(),
+ BlobUtils.diff(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId(),
ObjectId.zeroId(), null);
}
@@ -325,7 +317,7 @@ public void getRawContentNullRepo2() {
*/
@Test(expected = IllegalArgumentException.class)
public void getRawContentNullCommitId() throws IOException {
- BlobUtils.getRawContent(new FileRepository(testRepo), (ObjectId) null,
+ BlobUtils.getRawContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), (ObjectId) null,
"test.txt");
}
@@ -336,7 +328,7 @@ public void getRawContentNullCommitId() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getRawContentNullRevision() throws IOException {
- BlobUtils.getRawContent(new FileRepository(testRepo), (String) null,
+ BlobUtils.getRawContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), (String) null,
"test.txt");
}
@@ -347,7 +339,7 @@ public void getRawContentNullRevision() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getRawContentEmptyRevision() throws IOException {
- BlobUtils.getRawContent(new FileRepository(testRepo), "", "test.txt");
+ BlobUtils.getRawContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), "", "test.txt");
}
/**
@@ -357,7 +349,7 @@ public void getRawContentEmptyRevision() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getRawContentNullPath() throws IOException {
- BlobUtils.getRawContent(new FileRepository(testRepo),
+ BlobUtils.getRawContent(new FileRepositoryBuilder().setGitDir(testRepo).build(),
ObjectId.zeroId(), null);
}
@@ -368,7 +360,7 @@ public void getRawContentNullPath() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getRawContentNullPath2() throws IOException {
- BlobUtils.getRawContent(new FileRepository(testRepo), "master", null);
+ BlobUtils.getRawContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), "master", null);
}
/**
@@ -378,7 +370,7 @@ public void getRawContentNullPath2() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getRawContentEmptyPath() throws IOException {
- BlobUtils.getRawContent(new FileRepository(testRepo),
+ BlobUtils.getRawContent(new FileRepositoryBuilder().setGitDir(testRepo).build(),
ObjectId.zeroId(), "");
}
@@ -389,7 +381,7 @@ public void getRawContentEmptyPath() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getRawContentEmptyPath2() throws IOException {
- BlobUtils.getRawContent(new FileRepository(testRepo), "master", "");
+ BlobUtils.getRawContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), "master", "");
}
/**
@@ -400,8 +392,7 @@ public void getRawContentEmptyPath2() throws IOException {
@Test
public void getContent() throws Exception {
RevCommit commit = add("test.txt", "content");
- assertEquals("content", BlobUtils.getContent(new FileRepository(
- testRepo), commit, "test.txt"));
+ assertEquals("content", BlobUtils.getContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), commit, "test.txt"));
}
/**
@@ -412,8 +403,7 @@ public void getContent() throws Exception {
@Test
public void getStream() throws Exception {
RevCommit commit = add("test.txt", "content");
- assertNotNull("content", BlobUtils.getStream(new FileRepository(
- testRepo), commit, "test.txt"));
+ assertNotNull("content", BlobUtils.getStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), commit, "test.txt"));
}
/**
@@ -424,7 +414,7 @@ public void getStream() throws Exception {
@Test
public void getStreamNonExistentPath() throws Exception {
RevCommit commit = add("test.txt", "content");
- assertNull("content", BlobUtils.getStream(new FileRepository(testRepo),
+ assertNull("content", BlobUtils.getStream(new FileRepositoryBuilder().setGitDir(testRepo).build(),
commit, "test2.txt"));
}
@@ -436,8 +426,7 @@ public void getStreamNonExistentPath() throws Exception {
@Test
public void getHeadStreamNonExistentPath() throws Exception {
add("test.txt", "content");
- assertNull("content", BlobUtils.getHeadStream(new FileRepository(
- testRepo), "test2.txt"));
+ assertNull("content", BlobUtils.getHeadStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), "test2.txt"));
}
/**
@@ -448,8 +437,7 @@ public void getHeadStreamNonExistentPath() throws Exception {
@Test
public void getHeadStream() throws Exception {
add("test.txt", "content");
- assertNotNull("content", BlobUtils.getHeadStream(new FileRepository(
- testRepo), "test.txt"));
+ assertNotNull("content", BlobUtils.getHeadStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), "test.txt"));
}
/**
@@ -479,7 +467,7 @@ public void getStreamNullRepo2() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getStreamNullId() throws Exception {
- BlobUtils.getStream(new FileRepository(testRepo), (ObjectId) null,
+ BlobUtils.getStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), (ObjectId) null,
"test.txt");
}
@@ -490,7 +478,7 @@ public void getStreamNullId() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getStreamNullRevision() throws Exception {
- BlobUtils.getStream(new FileRepository(testRepo), (String) null,
+ BlobUtils.getStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), (String) null,
"test.txt");
}
@@ -501,7 +489,7 @@ public void getStreamNullRevision() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getStreamEmptyRevision() throws Exception {
- BlobUtils.getStream(new FileRepository(testRepo), "", "test.txt");
+ BlobUtils.getStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), "", "test.txt");
}
/**
@@ -511,7 +499,7 @@ public void getStreamEmptyRevision() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getStreamNullPath() throws Exception {
- BlobUtils.getStream(new FileRepository(testRepo), ObjectId.zeroId(),
+ BlobUtils.getStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId(),
null);
}
@@ -522,7 +510,7 @@ public void getStreamNullPath() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getStreamNullPath2() throws Exception {
- BlobUtils.getStream(new FileRepository(testRepo), "master", null);
+ BlobUtils.getStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), "master", null);
}
/**
@@ -533,7 +521,7 @@ public void getStreamNullPath2() throws Exception {
@Test(expected = IllegalArgumentException.class)
public void getStreamEmptyPath() throws Exception {
BlobUtils
- .getStream(new FileRepository(testRepo), ObjectId.zeroId(), "");
+ .getStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId(), "");
}
/**
@@ -543,7 +531,7 @@ public void getStreamEmptyPath() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getStreamEmptyPath2() throws Exception {
- BlobUtils.getStream(new FileRepository(testRepo), "master", "");
+ BlobUtils.getStream(new FileRepositoryBuilder().setGitDir(testRepo).build(), "master", "");
}
/**
@@ -554,8 +542,7 @@ public void getStreamEmptyPath2() throws Exception {
@Test
public void getHeadContent() throws Exception {
add("test.txt", "content");
- assertEquals("content", BlobUtils.getHeadContent(new FileRepository(
- testRepo), "test.txt"));
+ assertEquals("content", BlobUtils.getHeadContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), "test.txt"));
}
/**
@@ -567,7 +554,7 @@ public void getHeadContent() throws Exception {
public void getRawHeadContent() throws Exception {
add("test.txt", "content");
assertArrayEquals("content".getBytes(Constants.CHARACTER_ENCODING),
- BlobUtils.getRawHeadContent(new FileRepository(testRepo),
+ BlobUtils.getRawHeadContent(new FileRepositoryBuilder().setGitDir(testRepo).build(),
"test.txt"));
}
@@ -579,7 +566,7 @@ public void getRawHeadContent() throws Exception {
@Test
public void getHeadContentNonExistentPath() throws Exception {
add("test.txt", "content");
- assertNull(BlobUtils.getHeadContent(new FileRepository(testRepo),
+ assertNull(BlobUtils.getHeadContent(new FileRepositoryBuilder().setGitDir(testRepo).build(),
"test2.txt"));
}
@@ -592,7 +579,7 @@ public void getHeadContentNonExistentPath() throws Exception {
public void getHeadContentDirectoryPath() throws Exception {
add("src/test.txt", "content");
assertNull(BlobUtils
- .getHeadContent(new FileRepository(testRepo), "src"));
+ .getHeadContent(new FileRepositoryBuilder().setGitDir(testRepo).build(), "src"));
}
/**
@@ -623,7 +610,7 @@ public void getIdNullRepository2() throws Exception {
@Test(expected = IllegalArgumentException.class)
public void getIdNullRevision() throws Exception {
BlobUtils
- .getId(new FileRepository(testRepo), (String) null, "test.txt");
+ .getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), (String) null, "test.txt");
}
/**
@@ -633,7 +620,7 @@ public void getIdNullRevision() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdEmptyRevision() throws Exception {
- BlobUtils.getId(new FileRepository(testRepo), "", "test.txt");
+ BlobUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), "", "test.txt");
}
/**
@@ -643,7 +630,7 @@ public void getIdEmptyRevision() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdNullId() throws Exception {
- BlobUtils.getId(new FileRepository(testRepo), (ObjectId) null,
+ BlobUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), (ObjectId) null,
"test.txt");
}
@@ -654,7 +641,7 @@ public void getIdNullId() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdNullPath() throws Exception {
- BlobUtils.getId(new FileRepository(testRepo), ObjectId.zeroId(), null);
+ BlobUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId(), null);
}
/**
@@ -664,7 +651,7 @@ public void getIdNullPath() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdNullPath2() throws Exception {
- BlobUtils.getId(new FileRepository(testRepo), "master", null);
+ BlobUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), "master", null);
}
/**
@@ -674,7 +661,7 @@ public void getIdNullPath2() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdEmptyPath() throws Exception {
- BlobUtils.getId(new FileRepository(testRepo), ObjectId.zeroId(), "");
+ BlobUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId(), "");
}
/**
@@ -684,7 +671,7 @@ public void getIdEmptyPath() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdEmptyPath2() throws Exception {
- BlobUtils.getId(new FileRepository(testRepo), "master", "");
+ BlobUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), "master", "");
}
/**
@@ -695,7 +682,7 @@ public void getIdEmptyPath2() throws Exception {
@Test
public void getHeadId() throws Exception {
add("test.txt", "content");
- assertNotNull(BlobUtils.getHeadId(new FileRepository(testRepo),
+ assertNotNull(BlobUtils.getHeadId(new FileRepositoryBuilder().setGitDir(testRepo).build(),
"test.txt"));
}
@@ -707,7 +694,7 @@ public void getHeadId() throws Exception {
@Test
public void getId() throws Exception {
RevCommit commit = add("test.txt", "content");
- assertNotNull(BlobUtils.getId(new FileRepository(testRepo), commit,
+ assertNotNull(BlobUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), commit,
"test.txt"));
}
}
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/CommitBaseTest.java b/org.gitective.core/src/test/java/org/gitective/tests/CommitBaseTest.java
index 9176b42..2ebc5d3 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/CommitBaseTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/CommitBaseTest.java
@@ -24,7 +24,7 @@
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.gitective.core.CommitFinder;
import org.gitective.core.CommitUtils;
import org.gitective.core.filter.commit.CommitListFilter;
@@ -50,7 +50,10 @@ public void baseCommits() throws Exception {
RevCommit commit2 = add("file.txt", "edit 1");
RevCommit commit3 = add("file.txt", "edit 2");
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder()
+ .setGitDir(testRepo)
+ .readEnvironment()
+ .build();
RevCommit base = CommitUtils
.getBase(repo, Constants.MASTER, "release1");
assertEquals(commit1, base);
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/CommitTreeFilterTest.java b/org.gitective.core/src/test/java/org/gitective/tests/CommitTreeFilterTest.java
index 28820c9..83cf949 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/CommitTreeFilterTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/CommitTreeFilterTest.java
@@ -26,7 +26,7 @@
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.gitective.core.filter.tree.BaseTreeFilter;
import org.gitective.core.filter.tree.CommitTreeFilter;
@@ -88,7 +88,7 @@ public BaseTreeFilter setRepository(Repository repository) {
}
};
CommitTreeFilter filter = new CommitTreeFilter(treeFilter);
- Repository fileRepo = new FileRepository(testRepo);
+ Repository fileRepo = new FileRepositoryBuilder().setGitDir(testRepo).build();
filter.setRepository(fileRepo);
assertNotNull(repo.get());
assertEquals(fileRepo.getDirectory(), repo.get().getDirectory());
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/CommitUtilsTest.java b/org.gitective.core/src/test/java/org/gitective/tests/CommitUtilsTest.java
index 89de045..2632804 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/CommitUtilsTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/CommitUtilsTest.java
@@ -24,12 +24,10 @@
import java.io.IOException;
import java.util.Collection;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
+import org.eclipse.jgit.lib.*;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.gitective.core.CommitUtils;
import org.gitective.core.GitException;
import org.junit.Test;
@@ -58,7 +56,7 @@ public void tagRef() throws Exception {
add("a.txt", "a");
RevCommit commit = add("test.txt", "content");
tag(testRepo, "tag1");
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
RevCommit refCommit = CommitUtils.getRef(repo, "tag1");
assertNotNull(refCommit);
assertEquals(commit, refCommit);
@@ -75,7 +73,7 @@ public void tagRef() throws Exception {
*/
@Test
public void invalidRef() throws Exception {
- RevCommit commit = CommitUtils.getRef(new FileRepository(testRepo),
+ RevCommit commit = CommitUtils.getRef(new FileRepositoryBuilder().setGitDir(testRepo).build(),
"notatag");
assertNull(commit);
}
@@ -90,7 +88,7 @@ public void branchRef() throws Exception {
add("a.txt", "a");
RevCommit commit = add("test.txt", "content");
Ref ref = branch(testRepo, "branch1");
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
RevCommit refCommit = CommitUtils.getRef(repo, ref);
assertNotNull(refCommit);
assertEquals(commit, refCommit);
@@ -123,7 +121,7 @@ public void getCommitWithNullRepository2() {
*/
@Test(expected = IllegalArgumentException.class)
public void getCommitWithNullObjectId() throws Exception {
- CommitUtils.getCommit(new FileRepository(testRepo), (ObjectId) null);
+ CommitUtils.getCommit(new FileRepositoryBuilder().setGitDir(testRepo).build(), (ObjectId) null);
}
/**
@@ -133,7 +131,7 @@ public void getCommitWithNullObjectId() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getCommitWithNullRevision() throws Exception {
- CommitUtils.getCommit(new FileRepository(testRepo), (String) null);
+ CommitUtils.getCommit(new FileRepositoryBuilder().setGitDir(testRepo).build(), (String) null);
}
/**
@@ -143,7 +141,7 @@ public void getCommitWithNullRevision() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getCommitWithEmptyRevision() throws Exception {
- CommitUtils.getCommit(new FileRepository(testRepo), "");
+ CommitUtils.getCommit(new FileRepositoryBuilder().setGitDir(testRepo).build(), "");
}
/**
@@ -169,7 +167,7 @@ public void getBaseWithNullRepository2() {
*/
@Test(expected = IllegalArgumentException.class)
public void getBaseWithNullIds() throws Exception {
- CommitUtils.getBase(new FileRepository(testRepo), (ObjectId[]) null);
+ CommitUtils.getBase(new FileRepositoryBuilder().setGitDir(testRepo).build(), (ObjectId[]) null);
}
/**
@@ -179,7 +177,7 @@ public void getBaseWithNullIds() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getBaseWithEmptyIds() throws Exception {
- CommitUtils.getBase(new FileRepository(testRepo), new ObjectId[0]);
+ CommitUtils.getBase(new FileRepositoryBuilder().setGitDir(testRepo).build(), new ObjectId[0]);
}
/**
@@ -189,7 +187,7 @@ public void getBaseWithEmptyIds() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getBaseWithNullRevisions() throws Exception {
- CommitUtils.getBase(new FileRepository(testRepo), (String[]) null);
+ CommitUtils.getBase(new FileRepositoryBuilder().setGitDir(testRepo).build(), (String[]) null);
}
/**
@@ -199,7 +197,7 @@ public void getBaseWithNullRevisions() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getBaseWithEmptyRevisions() throws Exception {
- CommitUtils.getBase(new FileRepository(testRepo), new String[0]);
+ CommitUtils.getBase(new FileRepositoryBuilder().setGitDir(testRepo).build(), new String[0]);
}
/**
@@ -209,7 +207,7 @@ public void getBaseWithEmptyRevisions() throws Exception {
*/
@Test(expected = GitException.class)
public void getBaseWithUnknownRevision() throws Exception {
- CommitUtils.getBase(new FileRepository(testRepo), "notaref");
+ CommitUtils.getBase(new FileRepositoryBuilder().setGitDir(testRepo).build(), "notaref");
}
/**
@@ -235,7 +233,7 @@ public void getRefWithNullRepository2() {
*/
@Test(expected = IllegalArgumentException.class)
public void getRefWithNullRef() throws Exception {
- CommitUtils.getRef(new FileRepository(testRepo), (Ref) null);
+ CommitUtils.getRef(new FileRepositoryBuilder().setGitDir(testRepo).build(), (Ref) null);
}
/**
@@ -245,7 +243,7 @@ public void getRefWithNullRef() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getRefWithNullRefName() throws Exception {
- CommitUtils.getRef(new FileRepository(testRepo), (String) null);
+ CommitUtils.getRef(new FileRepositoryBuilder().setGitDir(testRepo).build(), (String) null);
}
/**
@@ -255,7 +253,7 @@ public void getRefWithNullRefName() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getRefWithEmptyRefName() throws Exception {
- CommitUtils.getRef(new FileRepository(testRepo), "");
+ CommitUtils.getRef(new FileRepositoryBuilder().setGitDir(testRepo).build(), "");
}
/**
@@ -346,7 +344,7 @@ public Ref getLeaf() {
return null;
}
};
- assertNull(CommitUtils.getRef(new FileRepository(testRepo), ref));
+ assertNull(CommitUtils.getRef(new FileRepositoryBuilder().setGitDir(testRepo).build(), ref));
}
/**
@@ -390,7 +388,7 @@ public Ref getLeaf() {
return null;
}
};
- CommitUtils.getRef(new FileRepository(testRepo), ref);
+ CommitUtils.getRef(new FileRepositoryBuilder().setGitDir(testRepo).build(), ref);
}
/**
@@ -400,7 +398,7 @@ public Ref getLeaf() {
*/
@Test(expected = GitException.class)
public void getBaseWithZeroId() throws Exception {
- CommitUtils.getBase(new FileRepository(testRepo), ObjectId.zeroId());
+ CommitUtils.getBase(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId());
}
/**
@@ -410,7 +408,7 @@ public void getBaseWithZeroId() throws Exception {
*/
@Test(expected = GitException.class)
public void getCommitWithZeroId() throws Exception {
- CommitUtils.getCommit(new FileRepository(testRepo), ObjectId.zeroId());
+ CommitUtils.getCommit(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId());
}
/**
@@ -443,7 +441,7 @@ public void getLastCommitNullRepository() {
*/
@Test(expected = IllegalArgumentException.class)
public void getLastCommitNullPath() throws Exception {
- CommitUtils.getLastCommit(new FileRepository(testRepo), null);
+ CommitUtils.getLastCommit(new FileRepositoryBuilder().setGitDir(testRepo).build(), null);
}
/**
@@ -453,7 +451,7 @@ public void getLastCommitNullPath() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getLastCommitEmptyPath() throws Exception {
- CommitUtils.getLastCommit(new FileRepository(testRepo), "");
+ CommitUtils.getLastCommit(new FileRepositoryBuilder().setGitDir(testRepo).build(), "");
}
/**
@@ -464,7 +462,7 @@ public void getLastCommitEmptyPath() throws Exception {
@Test(expected = IllegalArgumentException.class)
public void getLastCommitNullRevision() throws Exception {
CommitUtils
- .getLastCommit(new FileRepository(testRepo), null, "d/f.txt");
+ .getLastCommit(new FileRepositoryBuilder().setGitDir(testRepo).build(), null, "d/f.txt");
}
/**
@@ -474,6 +472,6 @@ public void getLastCommitNullRevision() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void getLastCommitEmptyRevision() throws Exception {
- CommitUtils.getLastCommit(new FileRepository(testRepo), "", "d/f.txt");
+ CommitUtils.getLastCommit(new FileRepositoryBuilder().setGitDir(testRepo).build(), "", "d/f.txt");
}
}
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/CursorTest.java b/org.gitective.core/src/test/java/org/gitective/tests/CursorTest.java
index df21dc1..9877ccd 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/CursorTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/CursorTest.java
@@ -26,13 +26,10 @@
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.filter.RevFilter;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.gitective.core.CommitFinder;
import org.gitective.core.CommitUtils;
-import org.gitective.core.filter.commit.AndCommitFilter;
-import org.gitective.core.filter.commit.CommitCursorFilter;
-import org.gitective.core.filter.commit.CommitLimitFilter;
-import org.gitective.core.filter.commit.CommitListFilter;
+import org.gitective.core.filter.commit.*;
import org.junit.Test;
/**
@@ -61,7 +58,7 @@ public void chunk() throws Exception {
limit, bucket));
service.setFilter(cursor);
int chunks = 0;
- RevCommit commit = CommitUtils.getHead(new FileRepository(testRepo));
+ RevCommit commit = CommitUtils.getHead(new FileRepositoryBuilder().setGitDir(testRepo).build());
while (commit != null) {
service.findFrom(commit);
assertEquals(limit.getLimit(), bucket.getCommits().size());
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/GitExceptionTest.java b/org.gitective.core/src/test/java/org/gitective/tests/GitExceptionTest.java
index f99bdb9..34ead61 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/GitExceptionTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/GitExceptionTest.java
@@ -23,7 +23,8 @@
import java.io.IOException;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.gitective.core.GitException;
import org.junit.Test;
@@ -41,7 +42,7 @@ public class GitExceptionTest extends GitTestCase {
public void constructors() throws IOException {
String message = "test";
NullPointerException cause = new NullPointerException();
- FileRepository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
GitException exception = new GitException(message, repo);
assertEquals(repo, exception.getRepository());
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/LastCommitDiffFilterTest.java b/org.gitective.core/src/test/java/org/gitective/tests/LastCommitDiffFilterTest.java
index 00715d3..3684873 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/LastCommitDiffFilterTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/LastCommitDiffFilterTest.java
@@ -24,7 +24,7 @@
import java.util.Map;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.gitective.core.CommitFinder;
import org.gitective.core.CommitUtils;
import org.gitective.core.filter.commit.LastCommitDiffFilter;
@@ -113,8 +113,7 @@ public void getHeadCommitsWithMergedFile() throws Exception {
checkout("master");
RevCommit commit3 = add("b.txt", "b");
merge("b1");
- assertFalse(commit3.equals(CommitUtils.getHead(new FileRepository(
- testRepo))));
+ assertFalse(commit3.equals(CommitUtils.getHead(new FileRepositoryBuilder().setGitDir(testRepo).build())));
LastCommitDiffFilter filter = new LastCommitDiffFilter();
new CommitFinder(testRepo).setFilter(filter).find();
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/LatestTest.java b/org.gitective.core/src/test/java/org/gitective/tests/LatestTest.java
index 209f96d..60c0e33 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/LatestTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/LatestTest.java
@@ -22,7 +22,7 @@
package org.gitective.tests;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.gitective.core.CommitUtils;
import org.junit.Test;
@@ -39,9 +39,9 @@ public class LatestTest extends GitTestCase {
@Test
public void latest() throws Exception {
RevCommit commit = add("file.txt", "content");
- assertEquals(commit, CommitUtils.getHead(new FileRepository(testRepo)));
+ assertEquals(commit, CommitUtils.getHead(new FileRepositoryBuilder().setGitDir(testRepo).build()));
assertEquals(commit,
- CommitUtils.getMaster(new FileRepository(testRepo)));
+ CommitUtils.getMaster(new FileRepositoryBuilder().setGitDir(testRepo).build()));
}
/**
@@ -50,7 +50,7 @@ public void latest() throws Exception {
* @throws Exception
*/
public void latestOnEmptyRepository() throws Exception {
- assertNull(CommitUtils.getHead(new FileRepository(testRepo)));
+ assertNull(CommitUtils.getHead(new FileRepositoryBuilder().setGitDir(testRepo).build()));
}
/**
@@ -62,6 +62,6 @@ public void latestOnEmptyRepository() throws Exception {
public void byId() throws Exception {
RevCommit commit = add("file.txt", "content");
assertEquals(commit,
- CommitUtils.getCommit(new FileRepository(testRepo), commit));
+ CommitUtils.getCommit(new FileRepositoryBuilder().setGitDir(testRepo).build(), commit));
}
}
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/MultiRepoTest.java b/org.gitective.core/src/test/java/org/gitective/tests/MultiRepoTest.java
index 3c8c4d3..82ba720 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/MultiRepoTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/MultiRepoTest.java
@@ -24,7 +24,7 @@
import java.io.File;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.gitective.core.CommitFinder;
import org.gitective.core.filter.commit.CommitCountFilter;
import org.junit.Test;
@@ -42,7 +42,7 @@ public class MultiRepoTest extends GitTestCase {
@Test
public void constructors() throws Exception {
new CommitFinder(testRepo);
- new CommitFinder(new FileRepository(testRepo));
+ new CommitFinder(new FileRepositoryBuilder().setGitDir(testRepo).build());
new CommitFinder(testRepo.getAbsolutePath());
}
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/RepositoryUtilsTest.java b/org.gitective.core/src/test/java/org/gitective/tests/RepositoryUtilsTest.java
index ebe79b1..e249419 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/RepositoryUtilsTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/RepositoryUtilsTest.java
@@ -22,18 +22,12 @@
package org.gitective.tests;
import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.PersonIdent;
-import org.eclipse.jgit.lib.RefUpdate;
-import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
+import org.eclipse.jgit.lib.*;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish;
import org.gitective.core.RepositoryUtils;
@@ -84,7 +78,7 @@ public void branchesForNullRepository() {
@Test
public void branchesForEmptyRepository() throws Exception {
Collection branches = RepositoryUtils
- .getBranches(new FileRepository(testRepo));
+ .getBranches(new FileRepositoryBuilder().setGitDir(testRepo).build());
assertNotNull(branches);
assertTrue(branches.isEmpty());
}
@@ -98,7 +92,7 @@ public void branchesForEmptyRepository() throws Exception {
public void branchesForRepository() throws Exception {
add("test.txt", "content");
Collection branches = RepositoryUtils
- .getBranches(new FileRepository(testRepo));
+ .getBranches(new FileRepositoryBuilder().setGitDir(testRepo).build());
assertNotNull(branches);
assertFalse(branches.isEmpty());
assertEquals(Constants.R_HEADS + Constants.MASTER, branches.iterator()
@@ -121,7 +115,7 @@ public void tagsForNullRepository() {
@Test
public void tagsForEmptyRepository() throws Exception {
Collection branches = RepositoryUtils
- .getBranches(new FileRepository(testRepo));
+ .getBranches(new FileRepositoryBuilder().setGitDir(testRepo).build());
assertNotNull(branches);
assertTrue(branches.isEmpty());
}
@@ -150,7 +144,7 @@ public void tagsForRepository() throws Exception {
@Test
public void noteRefsForEmptyRepository() throws Exception {
Collection noteRefs = RepositoryUtils
- .getNoteRefs(new FileRepository(testRepo));
+ .getNoteRefs(new FileRepositoryBuilder().setGitDir(testRepo).build());
assertNotNull(noteRefs);
assertTrue(noteRefs.isEmpty());
}
@@ -163,7 +157,7 @@ public void noteRefsForEmptyRepository() throws Exception {
@Test
public void noRemoteChanges() throws Exception {
add("test.txt", "content");
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
Collection diffs = RepositoryUtils.diffRemoteRefs(repo,
testRepo.toURI().toString());
assertNotNull(diffs);
@@ -180,7 +174,7 @@ public void oneRemoteChangeUsingUri() throws Exception {
RevCommit commit1 = add("test.txt", "content");
File repo2 = initRepo();
RevCommit commit2 = add(repo2, "test2.txt", "content2.txt");
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
Collection diffs = RepositoryUtils.diffRemoteRefs(repo, repo2
.toURI().toString());
assertNotNull(diffs);
@@ -202,7 +196,7 @@ public void oneOriginChange() throws Exception {
RevCommit commit1 = add("test.txt", "content");
File repo2 = initRepo();
RevCommit commit2 = add(repo2, "test2.txt", "content2.txt");
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
RefUpdate originMaster = repo.updateRef(Constants.R_REMOTES
+ Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER);
originMaster.setNewObjectId(commit1);
@@ -237,7 +231,7 @@ public void noRemoteChangesNullRepository() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void noRemoteChangesNullRemote() throws Exception {
- RepositoryUtils.diffRemoteRefs(new FileRepository(testRepo), null);
+ RepositoryUtils.diffRemoteRefs(new FileRepositoryBuilder().setGitDir(testRepo).build(), null);
}
/**
@@ -247,7 +241,7 @@ public void noRemoteChangesNullRemote() throws Exception {
*/
@Test(expected = IllegalArgumentException.class)
public void noRemoteChangesEmptyRemote() throws Exception {
- RepositoryUtils.diffRemoteRefs(new FileRepository(testRepo), "");
+ RepositoryUtils.diffRemoteRefs(new FileRepositoryBuilder().setGitDir(testRepo).build(), "");
}
/**
@@ -267,21 +261,16 @@ public void mapNamesToEmail() {
PersonIdent person1 = new PersonIdent("a", "b1");
PersonIdent person2 = new PersonIdent("a", "b2");
PersonIdent person3 = new PersonIdent("b", "c1");
- PersonIdent person4 = new PersonIdent(null, "c2");
- PersonIdent person5 = new PersonIdent("", "c2");
- PersonIdent person6 = new PersonIdent("c", null);
+ PersonIdent person4 = new PersonIdent("", "c2");
Map> mapped = RepositoryUtils
- .mapNamesToEmails(Arrays.asList(person1, person2, person3,
- person4, person5, person6));
+ .mapNamesToEmails(Arrays.asList(person1, person2, person3, person4));
assertNotNull(mapped);
assertFalse(mapped.isEmpty());
- assertEquals(3, mapped.size());
+ assertEquals(2, mapped.size());
assertNotNull(mapped.get("a"));
assertEquals(2, mapped.get("a").size());
assertNotNull(mapped.get("b"));
assertEquals(1, mapped.get("b").size());
- assertNotNull(mapped.get("c"));
- assertEquals(0, mapped.get("c").size());
assertTrue(mapped.get("a").contains("b1"));
assertTrue(mapped.get("a").contains("b2"));
assertTrue(mapped.get("b").contains("c1"));
@@ -304,21 +293,16 @@ public void mapEmailsToNames() {
PersonIdent person1 = new PersonIdent("b1", "a");
PersonIdent person2 = new PersonIdent("b2", "a");
PersonIdent person3 = new PersonIdent("c1", "b");
- PersonIdent person4 = new PersonIdent("c2", null);
- PersonIdent person5 = new PersonIdent("c2", "");
- PersonIdent person6 = new PersonIdent(null, "c");
+ PersonIdent person4 = new PersonIdent("c2", "");
Map> mapped = RepositoryUtils
- .mapEmailsToNames(Arrays.asList(person1, person2, person3,
- person4, person5, person6));
+ .mapEmailsToNames(Arrays.asList(person1, person2, person3, person4));
assertNotNull(mapped);
assertFalse(mapped.isEmpty());
- assertEquals(3, mapped.size());
+ assertEquals(2, mapped.size());
assertNotNull(mapped.get("a"));
assertEquals(2, mapped.get("a").size());
assertNotNull(mapped.get("b"));
assertEquals(1, mapped.get("b").size());
- assertNotNull(mapped.get("c"));
- assertEquals(0, mapped.get("c").size());
assertTrue(mapped.get("a").contains("b1"));
assertTrue(mapped.get("a").contains("b2"));
assertTrue(mapped.get("b").contains("c1"));
diff --git a/org.gitective.core/src/test/java/org/gitective/tests/TreeUtilsTest.java b/org.gitective.core/src/test/java/org/gitective/tests/TreeUtilsTest.java
index 49d1f4d..29335ce 100644
--- a/org.gitective.core/src/test/java/org/gitective/tests/TreeUtilsTest.java
+++ b/org.gitective.core/src/test/java/org/gitective/tests/TreeUtilsTest.java
@@ -21,30 +21,22 @@
*/
package org.gitective.tests;
-import static org.eclipse.jgit.lib.FileMode.REGULAR_FILE;
-import static org.eclipse.jgit.lib.FileMode.TREE;
-
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
-import org.eclipse.jgit.lib.AnyObjectId;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.FileMode;
-import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.*;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.gitective.core.BlobUtils;
import org.gitective.core.TreeUtils;
import org.gitective.core.TreeUtils.ITreeVisitor;
import org.junit.Test;
+import static org.eclipse.jgit.lib.FileMode.REGULAR_FILE;
+import static org.eclipse.jgit.lib.FileMode.TREE;
+
/**
* Unit tests of {@link TreeUtils}
*/
@@ -73,7 +65,7 @@ public void withParentsNullRepository2() {
*/
@Test(expected = IllegalArgumentException.class)
public void withParentsNullId() throws IOException {
- TreeUtils.withParents(new FileRepository(testRepo), (ObjectId) null);
+ TreeUtils.withParents(new FileRepositoryBuilder().setGitDir(testRepo).build(), (ObjectId) null);
}
/**
@@ -83,7 +75,7 @@ public void withParentsNullId() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void withParentsNullRevision() throws IOException {
- TreeUtils.withParents(new FileRepository(testRepo), (String) null);
+ TreeUtils.withParents(new FileRepositoryBuilder().setGitDir(testRepo).build(), (String) null);
}
/**
@@ -93,7 +85,7 @@ public void withParentsNullRevision() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void withParentsEmptyRevision() throws IOException {
- TreeUtils.withParents(new FileRepository(testRepo), "");
+ TreeUtils.withParents(new FileRepositoryBuilder().setGitDir(testRepo).build(), "");
}
/**
@@ -104,7 +96,7 @@ public void withParentsEmptyRevision() throws IOException {
@Test
public void diffWithNoParents() throws Exception {
RevCommit commit = add("test.txt", "content");
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
TreeWalk walk = TreeUtils.diffWithParents(repo, Constants.HEAD);
assertNotNull(walk);
assertEquals(2, walk.getTreeCount());
@@ -123,7 +115,7 @@ public void diffWithNoParents() throws Exception {
*/
@Test
public void diffWithOneParent() throws Exception {
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
RevCommit commit1 = add("test.txt", "content");
RevCommit commit2 = add("test.txt", "content2");
TreeWalk walk = TreeUtils.diffWithParents(repo, Constants.HEAD);
@@ -145,7 +137,7 @@ public void diffWithOneParent() throws Exception {
*/
@Test
public void diffRevisions() throws Exception {
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
RevCommit commit1 = add("test.txt", "content");
RevCommit commit2 = add("test.txt", "content2");
TreeWalk walk = TreeUtils.diffWithCommits(repo,
@@ -168,7 +160,7 @@ public void diffRevisions() throws Exception {
*/
@Test
public void diffCommits() throws Exception {
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
RevCommit commit1 = add("test.txt", "content");
RevCommit commit2 = add("test.txt", "content2");
TreeWalk walk = TreeUtils.diffWithCommits(repo, commit1, commit2);
@@ -206,7 +198,7 @@ public void withCommitsNullRepository2() {
*/
@Test(expected = IllegalArgumentException.class)
public void withCommitsNullIds() throws IOException {
- TreeUtils.withCommits(new FileRepository(testRepo), (ObjectId[]) null);
+ TreeUtils.withCommits(new FileRepositoryBuilder().setGitDir(testRepo).build(), (ObjectId[]) null);
}
/**
@@ -216,7 +208,7 @@ public void withCommitsNullIds() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void withCommitsNullRevision() throws IOException {
- TreeUtils.withCommits(new FileRepository(testRepo), (String[]) null);
+ TreeUtils.withCommits(new FileRepositoryBuilder().setGitDir(testRepo).build(), (String[]) null);
}
/**
@@ -226,7 +218,7 @@ public void withCommitsNullRevision() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void withCommitsEmptyRevision() throws IOException {
- TreeUtils.withCommits(new FileRepository(testRepo), new String[0]);
+ TreeUtils.withCommits(new FileRepositoryBuilder().setGitDir(testRepo).build(), new String[0]);
}
/**
@@ -236,7 +228,7 @@ public void withCommitsEmptyRevision() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void withCommitsEmptyCommits() throws IOException {
- TreeUtils.withCommits(new FileRepository(testRepo), new ObjectId[0]);
+ TreeUtils.withCommits(new FileRepositoryBuilder().setGitDir(testRepo).build(), new ObjectId[0]);
}
/**
@@ -263,7 +255,7 @@ public void getIdNullRepository2() {
@Test(expected = IllegalArgumentException.class)
public void getIdNullCommitId() throws IOException {
TreeUtils
- .getId(new FileRepository(testRepo), (ObjectId) null, "folder");
+ .getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), (ObjectId) null, "folder");
}
/**
@@ -273,7 +265,7 @@ public void getIdNullCommitId() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdNullRevision() throws IOException {
- TreeUtils.getId(new FileRepository(testRepo), (String) null, "folder");
+ TreeUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), (String) null, "folder");
}
/**
@@ -283,7 +275,7 @@ public void getIdNullRevision() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdEmptyRevision() throws IOException {
- TreeUtils.getId(new FileRepository(testRepo), "", "folder");
+ TreeUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), "", "folder");
}
/**
@@ -293,7 +285,7 @@ public void getIdEmptyRevision() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdNullPath1() throws IOException {
- TreeUtils.getId(new FileRepository(testRepo), ObjectId.zeroId(), null);
+ TreeUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId(), null);
}
/**
@@ -303,7 +295,7 @@ public void getIdNullPath1() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdNullPath2() throws IOException {
- TreeUtils.getId(new FileRepository(testRepo), Constants.MASTER, null);
+ TreeUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), Constants.MASTER, null);
}
/**
@@ -313,7 +305,7 @@ public void getIdNullPath2() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdEmptyPath1() throws IOException {
- TreeUtils.getId(new FileRepository(testRepo), ObjectId.zeroId(), "");
+ TreeUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId(), "");
}
/**
@@ -323,7 +315,7 @@ public void getIdEmptyPath1() throws IOException {
*/
@Test(expected = IllegalArgumentException.class)
public void getIdEmptyPath2() throws IOException {
- TreeUtils.getId(new FileRepository(testRepo), Constants.MASTER, "");
+ TreeUtils.getId(new FileRepositoryBuilder().setGitDir(testRepo).build(), Constants.MASTER, "");
}
/**
@@ -333,7 +325,7 @@ public void getIdEmptyPath2() throws IOException {
*/
@Test
public void getIdWithCommit() throws Exception {
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
RevCommit commit = add("d1/f1.txt", "content");
assertNull(TreeUtils.getId(repo, commit, "d2/f1.txt"));
assertNull(TreeUtils.getId(repo, commit, "d1/f1.txt"));
@@ -351,7 +343,7 @@ public void getIdWithCommit() throws Exception {
*/
@Test
public void getIdWithRevision() throws Exception {
- Repository repo = new FileRepository(testRepo);
+ Repository repo = new FileRepositoryBuilder().setGitDir(testRepo).build();
RevCommit commit = add("d1/f1.txt", "content");
assertNull(TreeUtils.getId(repo, Constants.MASTER, "d2/f1.txt"));
assertNull(TreeUtils.getId(repo, Constants.MASTER, "d1/f1.txt"));
@@ -383,7 +375,7 @@ public boolean accept(FileMode mode, String path, String name,
*/
@Test(expected = IllegalArgumentException.class)
public void visitNullTreeId() throws IOException {
- TreeUtils.visit(new FileRepository(testRepo), null, new ITreeVisitor() {
+ TreeUtils.visit(new FileRepositoryBuilder().setGitDir(testRepo).build(), null, new ITreeVisitor() {
public boolean accept(FileMode mode, String path, String name,
AnyObjectId id) {
@@ -399,7 +391,7 @@ public boolean accept(FileMode mode, String path, String name,
*/
@Test(expected = IllegalArgumentException.class)
public void visitNullVisitor() throws IOException {
- TreeUtils.visit(new FileRepository(testRepo), ObjectId.zeroId(), null);
+ TreeUtils.visit(new FileRepositoryBuilder().setGitDir(testRepo).build(), ObjectId.zeroId(), null);
}
/**
@@ -416,7 +408,7 @@ public void visit() throws Exception {
final AtomicInteger folders = new AtomicInteger(0);
final List fullPaths = new ArrayList();
final Set ids = new HashSet();
- assertTrue(TreeUtils.visit(new FileRepository(testRepo),
+ assertTrue(TreeUtils.visit(new FileRepositoryBuilder().setGitDir(testRepo).build(),
commit.getTree(), new ITreeVisitor() {
public boolean accept(FileMode mode, String path,