James Moger
2012-03-25 7db0929ad58804ebc235730b9cfc83dc38835eb9
Added web.allowLuceneIndexing to enable/disable Lucene integration
10 files modified
59 ■■■■ changed files
distrib/gitblit.properties 9 ●●●●● patch | view | raw | blame | history
docs/01_setup.mkd 8 ●●●● patch | view | raw | blame | history
docs/04_releases.mkd 4 ●●● patch | view | raw | blame | history
resources/gitblit.css 3 ●●●● patch | view | raw | blame | history
src/com/gitblit/LuceneExecutor.java 4 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/GitBlitWebApp.properties 3 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/EditRepositoryPage.java 5 ●●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/LuceneSearchPage.java 16 ●●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/RepositoryPage.java 3 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/RootPage.java 4 ●●● patch | view | raw | blame | history
distrib/gitblit.properties
@@ -184,6 +184,15 @@
# SINCE 0.5.0   
web.allowZipDownloads = true
# Allow optional Lucene integration. Lucene indexing is an opt-in feature.
# A repository may specify branches to index with Lucene instead of using Git
# commit traversal. There are scenarios where you may want to completely disable
# Lucene indexing despite a repository specifying indexed branches.  One such
# scenario is on a resource-constrained federated Gitblit mirror.
#
# SINCE 0.9.0
web.allowLuceneIndexing = true
# Use Clippy (Flash solution) to provide a copy-to-clipboard button.
# If false, a button with a more primitive JavaScript-based prompt box will
# offer a 3-step (click, ctrl+c, enter) copy-to-clipboard alternative.
docs/01_setup.mkd
@@ -385,11 +385,11 @@
### How do I use it?
Lucene indexing is an opt-in feature which means that no repositories are automatically indexed.
First you must ensure that *web.allowLuceneIndexing* is set *true* in `gitblit.properties` or `web.xml`.  Then you must understand that Lucene indexing is an opt-in feature which means that no repositories are automatically indexed.
Like anything else, this design has pros and cons.
#### Pros
1. no wasted cycles on repositories you will never search
1. no wasted cycles indexing repositories you will never search
2. you specify exactly what branches are indexed; experimental/dead/personal branches can be ignored
#### Cons
@@ -408,6 +408,10 @@
**NOTE:**  
After specifying branches, only the content from those branches can be searched via Gitblit.  Gitblit will automatically redirect any queries entered on a repository's search box to the Lucene search page. Repositories that do not specify any indexed branches will use the traditional commit-traversal search.
#### Adequate Heap
The initial indexing of an existing repository can potentially exhaust the memory allocated to your Java instance and may throw OutOfMemory exceptions.  Be sure to provide your Gitblit server adequate heap space to index your repositories.  The heap is set using the *-Xmx* JVM parameter in your Gitblit launch command (e.g. -Xmx1024M).
## Client Setup and Configuration
### Https with Self-Signed Certificates
You must tell Git/JGit not to verify the self-signed certificate in order to perform any remote Git operations.
docs/04_releases.mkd
@@ -17,10 +17,12 @@
#### additions
- Added optional Lucene branch indexing (issue 16)  
    **New:** *web.allowLuceneIndexing = true*
    **New:** *web.luceneIgnoreExtensions = 7z arc arj bin bmp dll doc docx exe gif gz jar jpg lib lzh odg odf odt pdf ppt png so swf xcf xls xlsx zip*  
Repository branches may be optionally indexed by Lucene for improved searching.  To use this feature you must specify which branches to index within the *Edit Repository* page; _no repositories are automatically indexed_.  Gitblit will build or incrementally update enrolled repositories on a 2 minute cycle. (i.e you will have to wait 2-3 minutes after respecifying indexed branches or pushing new commits before Gitblit will build/update the repository's Lucene index.)  
If a repository has Lucene-indexed branches the *search* form on the repository pages will redirect to the root-level Lucene search page and only the content of those branches can be searched.  
If the repository does not specify any indexed branches then repository commit-traversal search is used.
If the repository does not specify any indexed branches then repository commit-traversal search is used.
**Note:** Initial indexing of an existing repository can be memory-exhaustive. Be sure to provide your Gitblit server adequate heap space to index your repositories (e.g. -Xmx1024M).
- Allow specifying timezone to use for Gitblit which is independent of both the JVM and the system timezone (issue 54)  
    **New:** *web.timezone =*  
- Added a built-in AJP connector for integrating Gitblit GO into an Apache mod_proxy setup (issue 59)  
resources/gitblit.css
@@ -310,7 +310,8 @@
}
div.searchResult .text {
    border-left: 5px solid #EEEEEE;
    border-left: 2px solid #ccc;
    border-radius: 0px;
    
    padding: 0 0 0 15px;
}
src/com/gitblit/LuceneExecutor.java
@@ -157,6 +157,10 @@
     */
    @Override
    public void run() {
        if (!storedSettings.getBoolean(Keys.web.allowLuceneIndexing, true)) {
            // Lucene indexing is disabled
            return;
        }
        // reload the excluded extensions
        String exts = storedSettings.getString(Keys.web.luceneIgnoreExtensions, luceneIgnoreExtensions);
        excludedExtensions = new TreeSet<String>(StringUtils.getStringsFromValue(exts));
src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -222,4 +222,5 @@
gb.indexedBranchesDescription = select the branches to include in your Lucene index
gb.noIndexedRepositoriesWarning = none of your repositories are configured for Lucene indexing
gb.undefinedQueryWarning = query is undefined!
gb.noSelectedRepositoriesWarning = please select one or more repositories!
gb.noSelectedRepositoriesWarning = please select one or more repositories!
gb.luceneDisabled = Lucene indexing is disabled
src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -117,12 +117,11 @@
        // indexed local branches palette
        List<String> allLocalBranches = repositoryModel.getLocalBranches();
        boolean luceneEnabled = GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true);
        final Palette<String> indexedBranchesPalette = new Palette<String>("indexedBranches", new ListModel<String>(
                indexedBranches), new CollectionModel<String>(allLocalBranches),
                new StringChoiceRenderer(), 8, false);
        indexedBranchesPalette.setEnabled(allLocalBranches.size() > 0);
        indexedBranchesPalette.setEnabled(luceneEnabled && (allLocalBranches.size() > 0));
        
        // federation sets palette
        List<String> sets = GitBlit.getStrings(Keys.federation.sets);
src/com/gitblit/wicket/pages/LuceneSearchPage.java
@@ -105,9 +105,13 @@
                availableRepositories.add(model.name);
            }
        }
        if (availableRepositories.size() == 0) {
            info(getString("gb.noIndexedRepositoriesWarning"));
        boolean luceneEnabled = GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true);
        if (luceneEnabled) {
            if (availableRepositories.size() == 0) {
                info(getString("gb.noIndexedRepositoriesWarning"));
            }
        } else {
            error(getString("gb.luceneDisabled"));
        }
        // enforce user-accessible repository selections
@@ -146,9 +150,9 @@
        ListMultipleChoice<String> selections = new ListMultipleChoice<String>("repositories", 
                repositoriesModel, availableRepositories, new StringChoiceRenderer());
        selections.setMaxRows(8);
        form.add(selections);
        form.add(new TextField<String>("query", queryModel));
        add(form);
        form.add(selections.setEnabled(luceneEnabled));
        form.add(new TextField<String>("query", queryModel).setEnabled(luceneEnabled));
        add(form.setEnabled(luceneEnabled));
                
        // execute search
        final List<SearchResult> results = new ArrayList<SearchResult>();
src/com/gitblit/wicket/pages/RepositoryPage.java
@@ -360,7 +360,8 @@
            }
            Class<? extends BasePage> searchPageClass = GitSearchPage.class;
            RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);
            if (!ArrayUtils.isEmpty(model.indexedBranches)) {
            if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)
                    && !ArrayUtils.isEmpty(model.indexedBranches)) {
                // this repository is Lucene-indexed
                searchPageClass = LuceneSearchPage.class;
            }
src/com/gitblit/wicket/pages/RootPage.java
@@ -101,7 +101,9 @@
        pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class,
                getRootPageParameters()));
        pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters()));
        pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));
        if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)) {
            pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));
        }
        if (showAdmin) {
            pages.add(new PageRegistration("gb.users", UsersPage.class));
        }