summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/LuceneExecutor.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-03-27 16:51:35 -0400
committerJames Moger <james.moger@gitblit.com>2012-03-27 16:51:35 -0400
commit1aabf0a23f112f06cd7ea5e43a11c11bd177872b (patch)
treeae6db3666a1308ce01dbeecf4acb925802c08d70 /src/com/gitblit/LuceneExecutor.java
parent6caa9368cb639c14691713feb5aa16c9c0976240 (diff)
downloadgitblit-1aabf0a23f112f06cd7ea5e43a11c11bd177872b.tar.gz
gitblit-1aabf0a23f112f06cd7ea5e43a11c11bd177872b.zip
Implemented support for "default" branch
Diffstat (limited to 'src/com/gitblit/LuceneExecutor.java')
-rw-r--r--src/com/gitblit/LuceneExecutor.java63
1 files changed, 56 insertions, 7 deletions
diff --git a/src/com/gitblit/LuceneExecutor.java b/src/com/gitblit/LuceneExecutor.java
index 25ed9daf..961267b2 100644
--- a/src/com/gitblit/LuceneExecutor.java
+++ b/src/com/gitblit/LuceneExecutor.java
@@ -447,7 +447,7 @@ public class LuceneExecutor implements Runnable {
ObjectId defaultBranchId = JGitUtils.getDefaultBranch(repository);
for (RefModel branch : branches) {
if (branch.getObjectId().equals(defaultBranchId)) {
- defaultBranch = branch;
+ defaultBranch = branch;
break;
}
}
@@ -457,8 +457,22 @@ public class LuceneExecutor implements Runnable {
// walk through each branch
for (RefModel branch : branches) {
+ boolean indexBranch = false;
+ if (model.indexedBranches.contains(com.gitblit.Constants.DEFAULT_BRANCH)
+ && branch.equals(defaultBranch)) {
+ // indexing "default" branch
+ indexBranch = true;
+ } else if (IssueUtils.GB_ISSUES.equals(branch)) {
+ // skip the GB_ISSUES branch because it is indexed later
+ // note: this is different than updateIndex
+ indexBranch = false;
+ } else {
+ // normal explicit branch check
+ indexBranch = model.indexedBranches.contains(branch.getName());
+ }
+
// if this branch is not specifically indexed then skip
- if (!model.indexedBranches.contains(branch.getName())) {
+ if (!indexBranch) {
continue;
}
@@ -782,20 +796,55 @@ public class LuceneExecutor implements Runnable {
deletedBranches.add(branch);
}
- // walk through each branches
+ // get the local branches
List<RefModel> branches = JGitUtils.getLocalBranches(repository, true, -1);
+
+ // sort them by most recently updated
+ Collections.sort(branches, new Comparator<RefModel>() {
+ @Override
+ public int compare(RefModel ref1, RefModel ref2) {
+ return ref2.getDate().compareTo(ref1.getDate());
+ }
+ });
+
+ // reorder default branch to first position
+ RefModel defaultBranch = null;
+ ObjectId defaultBranchId = JGitUtils.getDefaultBranch(repository);
+ for (RefModel branch : branches) {
+ if (branch.getObjectId().equals(defaultBranchId)) {
+ defaultBranch = branch;
+ break;
+ }
+ }
+ branches.remove(defaultBranch);
+ branches.add(0, defaultBranch);
+
+ // walk through each branches
for (RefModel branch : branches) {
String branchName = branch.getName();
- // determine if we should skip this branch
- if (!IssueUtils.GB_ISSUES.equals(branch)
- && !model.indexedBranches.contains(branch.getName())) {
+ boolean indexBranch = false;
+ if (model.indexedBranches.contains(com.gitblit.Constants.DEFAULT_BRANCH)
+ && branch.equals(defaultBranch)) {
+ // indexing "default" branch
+ indexBranch = true;
+ } else if (IssueUtils.GB_ISSUES.equals(branch)) {
+ // update issues modified on the GB_ISSUES branch
+ // note: this is different than reindex
+ indexBranch = true;
+ } else {
+ // normal explicit branch check
+ indexBranch = model.indexedBranches.contains(branch.getName());
+ }
+
+ // if this branch is not specifically indexed then skip
+ if (!indexBranch) {
continue;
}
// remove this branch from the deletedBranches set
deletedBranches.remove(branchName);
-
+
// determine last commit
String keyName = getBranchKey(branchName);
String lastCommit = config.getString(CONF_BRANCH, null, keyName);