summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/gitblit/utils/LuceneUtils.java11
-rw-r--r--tests/com/gitblit/tests/GitBlitSuite.java2
-rw-r--r--tests/com/gitblit/tests/LuceneUtilsTest.java16
3 files changed, 20 insertions, 9 deletions
diff --git a/src/com/gitblit/utils/LuceneUtils.java b/src/com/gitblit/utils/LuceneUtils.java
index fe36a838..3b3c30e1 100644
--- a/src/com/gitblit/utils/LuceneUtils.java
+++ b/src/com/gitblit/utils/LuceneUtils.java
@@ -292,12 +292,13 @@ public class LuceneUtils {
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(branchHead.getTree());
treeWalk.setRecursive(true);
+
while (treeWalk.next()) {
result.blobCount++;
String blobPath = treeWalk.getPathString();
RevCommit blobRev = branchHead;
-
+
RevWalk blobWalk = null;
if (fullIndex) {
// XXX this is _really_ slow, there must be a better way
@@ -308,11 +309,7 @@ public class LuceneUtils {
PathFilterGroup.createFromStrings(Collections.singleton(blobPath)),
TreeFilter.ANY_DIFF);
blobWalk.setTreeFilter(filter);
-
- for (RevCommit commit : blobWalk) {
- blobRev = commit;
- break;
- }
+ blobRev = blobWalk.next();
}
String blobAuthor = getAuthor(blobRev);
@@ -321,7 +318,7 @@ public class LuceneUtils {
Resolution.MINUTE);
if (blobWalk != null) {
- blobWalk.dispose();
+ blobWalk.dispose();
}
Document doc = new Document();
diff --git a/tests/com/gitblit/tests/GitBlitSuite.java b/tests/com/gitblit/tests/GitBlitSuite.java
index bb55cfac..4a70964b 100644
--- a/tests/com/gitblit/tests/GitBlitSuite.java
+++ b/tests/com/gitblit/tests/GitBlitSuite.java
@@ -91,7 +91,7 @@ public class GitBlitSuite {
}
public static Repository getGitectiveRepository() throws Exception {
- return new FileRepository(new File("test/gitective.git"));
+ return new FileRepository(new File(REPOSITORIES, "test/gitective.git"));
}
public static boolean startGitblit() throws Exception {
diff --git a/tests/com/gitblit/tests/LuceneUtilsTest.java b/tests/com/gitblit/tests/LuceneUtilsTest.java
index 53710090..3b21e712 100644
--- a/tests/com/gitblit/tests/LuceneUtilsTest.java
+++ b/tests/com/gitblit/tests/LuceneUtilsTest.java
@@ -35,7 +35,7 @@ import com.gitblit.utils.StringUtils;
public class LuceneUtilsTest {
@Test
- public void testFullIndex() throws Exception {
+ public void testQuickIndex() throws Exception {
// reindex helloworld
Repository repository = GitBlitSuite.getHelloworldRepository();
String name = StringUtils.getRelativePath(GitBlitSuite.REPOSITORIES.getAbsolutePath(),
@@ -61,6 +61,20 @@ public class LuceneUtilsTest {
}
@Test
+ public void testFullIndex() throws Exception {
+ // reindex helloworld
+ Repository repository = GitBlitSuite.getHelloworldRepository();
+ String name = StringUtils.getRelativePath(GitBlitSuite.REPOSITORIES.getAbsolutePath(),
+ repository.getDirectory().getAbsolutePath());
+ LuceneUtils.reindex(name, repository, true);
+ SearchResult result = LuceneUtils.search("type:blob AND id:bit.bit", 1, repository).get(0);
+ repository.close();
+ assertEquals("Mike Donaghy", result.author);
+ //assertEquals("Mike Donaghy", result.date);
+ LuceneUtils.close();
+ }
+
+ @Test
public void testQuery() throws Exception {
// 2 occurrences on the master branch
Repository repository = GitBlitSuite.getHelloworldRepository();