]> source.dussan.org Git - gitblit.git/commitdiff
Lucene adjustments
authorJames Moger <james.moger@gitblit.com>
Sat, 10 Mar 2012 19:10:48 +0000 (14:10 -0500)
committerJames Moger <james.moger@gitblit.com>
Sat, 10 Mar 2012 19:10:48 +0000 (14:10 -0500)
src/com/gitblit/utils/LuceneUtils.java
tests/com/gitblit/tests/GitBlitSuite.java
tests/com/gitblit/tests/LuceneUtilsTest.java

index fe36a838044f056e8e91974f2d886c5dfe96a726..3b3c30e1244169bbdd685b2fa349f41ab4a0a3b7 100644 (file)
@@ -292,12 +292,13 @@ public class LuceneUtils {
                                TreeWalk treeWalk = new TreeWalk(repository);\r
                                treeWalk.addTree(branchHead.getTree());\r
                                treeWalk.setRecursive(true);\r
+                                                               \r
                                \r
                                while (treeWalk.next()) {\r
                                        result.blobCount++;\r
                                        String blobPath = treeWalk.getPathString();\r
                                        RevCommit blobRev = branchHead;\r
-                                       \r
+                               \r
                                        RevWalk blobWalk = null;\r
                                        if (fullIndex) {\r
                                                // XXX this is _really_ slow, there must be a better way\r
@@ -308,11 +309,7 @@ public class LuceneUtils {
                                                                PathFilterGroup.createFromStrings(Collections.singleton(blobPath)),\r
                                                                TreeFilter.ANY_DIFF);\r
                                                blobWalk.setTreeFilter(filter);\r
-\r
-                                               for (RevCommit commit : blobWalk) {\r
-                                                       blobRev = commit;\r
-                                                       break;\r
-                                               }\r
+                                               blobRev = blobWalk.next();\r
                                        }\r
                                        \r
                                        String blobAuthor = getAuthor(blobRev);\r
@@ -321,7 +318,7 @@ public class LuceneUtils {
                                                        Resolution.MINUTE);\r
                                        \r
                                        if (blobWalk != null) {\r
-                                               blobWalk.dispose();\r
+                                               blobWalk.dispose();                                             \r
                                        }\r
                                        \r
                                        Document doc = new Document();\r
index bb55cfacbc9c517820e83155b8af7c11a747a811..4a70964b718f59150c880cf6b4669a3c285cf33b 100644 (file)
@@ -91,7 +91,7 @@ public class GitBlitSuite {
        }\r
        \r
        public static Repository getGitectiveRepository() throws Exception {\r
-               return new FileRepository(new File("test/gitective.git"));\r
+               return new FileRepository(new File(REPOSITORIES, "test/gitective.git"));\r
        }\r
 \r
        public static boolean startGitblit() throws Exception {\r
index 537100908073efbb0a97eaa922d5bd8a91ed60bd..3b21e712439fe168c813ed9318a7ce87e4e8a550 100644 (file)
@@ -35,7 +35,7 @@ import com.gitblit.utils.StringUtils;
 public class LuceneUtilsTest {\r
 \r
        @Test\r
-       public void testFullIndex() throws Exception {\r
+       public void testQuickIndex() throws Exception {\r
                // reindex helloworld\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                String name = StringUtils.getRelativePath(GitBlitSuite.REPOSITORIES.getAbsolutePath(),\r
@@ -60,6 +60,20 @@ public class LuceneUtilsTest {
                LuceneUtils.close();\r
        }\r
 \r
+       @Test\r
+       public void testFullIndex() throws Exception {\r
+               // reindex helloworld\r
+               Repository repository = GitBlitSuite.getHelloworldRepository();\r
+               String name = StringUtils.getRelativePath(GitBlitSuite.REPOSITORIES.getAbsolutePath(),\r
+                               repository.getDirectory().getAbsolutePath());\r
+               LuceneUtils.reindex(name, repository, true);\r
+               SearchResult result = LuceneUtils.search("type:blob AND id:bit.bit", 1, repository).get(0);             \r
+               repository.close();\r
+               assertEquals("Mike Donaghy", result.author);\r
+               //assertEquals("Mike Donaghy", result.date);\r
+               LuceneUtils.close();\r
+       }\r
+\r
        @Test\r
        public void testQuery() throws Exception {\r
                // 2 occurrences on the master branch\r