\r
public static final int LEN_SHORTLOG_REFS = 60;\r
\r
+ public static final String DEFAULT_BRANCH = "default";\r
+ \r
public static String getGitBlitVersion() {\r
return NAME + " v" + VERSION;\r
}\r
ObjectId defaultBranchId = JGitUtils.getDefaultBranch(repository);\r
for (RefModel branch : branches) {\r
if (branch.getObjectId().equals(defaultBranchId)) {\r
- defaultBranch = branch; \r
+ defaultBranch = branch;\r
break;\r
}\r
}\r
// walk through each branch\r
for (RefModel branch : branches) {\r
\r
+ boolean indexBranch = false;\r
+ if (model.indexedBranches.contains(com.gitblit.Constants.DEFAULT_BRANCH)\r
+ && branch.equals(defaultBranch)) {\r
+ // indexing "default" branch\r
+ indexBranch = true;\r
+ } else if (IssueUtils.GB_ISSUES.equals(branch)) {\r
+ // skip the GB_ISSUES branch because it is indexed later\r
+ // note: this is different than updateIndex\r
+ indexBranch = false;\r
+ } else {\r
+ // normal explicit branch check\r
+ indexBranch = model.indexedBranches.contains(branch.getName());\r
+ }\r
+ \r
// if this branch is not specifically indexed then skip\r
- if (!model.indexedBranches.contains(branch.getName())) {\r
+ if (!indexBranch) {\r
continue;\r
}\r
\r
deletedBranches.add(branch);\r
}\r
\r
- // walk through each branches\r
+ // get the local branches\r
List<RefModel> branches = JGitUtils.getLocalBranches(repository, true, -1);\r
+ \r
+ // sort them by most recently updated\r
+ Collections.sort(branches, new Comparator<RefModel>() {\r
+ @Override\r
+ public int compare(RefModel ref1, RefModel ref2) {\r
+ return ref2.getDate().compareTo(ref1.getDate());\r
+ }\r
+ });\r
+ \r
+ // reorder default branch to first position\r
+ RefModel defaultBranch = null;\r
+ ObjectId defaultBranchId = JGitUtils.getDefaultBranch(repository);\r
+ for (RefModel branch : branches) {\r
+ if (branch.getObjectId().equals(defaultBranchId)) {\r
+ defaultBranch = branch;\r
+ break;\r
+ }\r
+ }\r
+ branches.remove(defaultBranch);\r
+ branches.add(0, defaultBranch);\r
+ \r
+ // walk through each branches\r
for (RefModel branch : branches) {\r
String branchName = branch.getName();\r
\r
- // determine if we should skip this branch\r
- if (!IssueUtils.GB_ISSUES.equals(branch)\r
- && !model.indexedBranches.contains(branch.getName())) {\r
+ boolean indexBranch = false;\r
+ if (model.indexedBranches.contains(com.gitblit.Constants.DEFAULT_BRANCH)\r
+ && branch.equals(defaultBranch)) {\r
+ // indexing "default" branch\r
+ indexBranch = true;\r
+ } else if (IssueUtils.GB_ISSUES.equals(branch)) {\r
+ // update issues modified on the GB_ISSUES branch\r
+ // note: this is different than reindex\r
+ indexBranch = true;\r
+ } else {\r
+ // normal explicit branch check\r
+ indexBranch = model.indexedBranches.contains(branch.getName());\r
+ }\r
+ \r
+ // if this branch is not specifically indexed then skip\r
+ if (!indexBranch) {\r
continue;\r
}\r
\r
// remove this branch from the deletedBranches set\r
deletedBranches.remove(branchName);\r
-\r
+ \r
// determine last commit\r
String keyName = getBranchKey(branchName);\r
String lastCommit = config.getString(CONF_BRANCH, null, keyName);\r
import java.awt.event.MouseEvent;\r
import java.io.IOException;\r
import java.util.ArrayList;\r
+import java.util.Arrays;\r
import java.util.List;\r
\r
import javax.swing.JButton;\r
import javax.swing.table.TableCellRenderer;\r
import javax.swing.table.TableRowSorter;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.Constants.RpcRequest;\r
import com.gitblit.models.FeedModel;\r
import com.gitblit.models.RepositoryModel;\r
dialog.setTeams(gitblit.getTeamnames(), null);\r
dialog.setRepositories(gitblit.getRepositories());\r
dialog.setFederationSets(gitblit.getFederationSets(), null);\r
- dialog.setIndexedBranches(new ArrayList<String>(), null);\r
+ dialog.setIndexedBranches(new ArrayList<String>(Arrays.asList(Constants.DEFAULT_BRANCH)), null);\r
dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(null),\r
gitblit.getPreReceiveScriptsInherited(null), null);\r
dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(null),\r
dialog.setTeams(gitblit.getTeamnames(), gitblit.getPermittedTeamnames(repository));\r
dialog.setRepositories(gitblit.getRepositories());\r
dialog.setFederationSets(gitblit.getFederationSets(), repository.federationSets);\r
- dialog.setIndexedBranches(repository.getLocalBranches(), repository.indexedBranches);\r
+ List<String> allLocalBranches = new ArrayList<String>();\r
+ allLocalBranches.add(Constants.DEFAULT_BRANCH);\r
+ allLocalBranches.addAll(repository.getLocalBranches());\r
+ dialog.setIndexedBranches(allLocalBranches, repository.indexedBranches);\r
dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(repository),\r
gitblit.getPreReceiveScriptsInherited(repository), repository.preReceiveScripts);\r
dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(repository),\r
\r
import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.Constants.FederationStrategy;\r
+import com.gitblit.Constants;\r
import com.gitblit.GitBlit;\r
import com.gitblit.GitBlitException;\r
import com.gitblit.Keys;\r
new StringChoiceRenderer(), 8, false);\r
\r
// indexed local branches palette\r
- List<String> allLocalBranches = repositoryModel.getLocalBranches();\r
+ List<String> allLocalBranches = new ArrayList<String>();\r
+ allLocalBranches.add(Constants.DEFAULT_BRANCH);\r
+ allLocalBranches.addAll(repositoryModel.getLocalBranches());\r
boolean luceneEnabled = GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true);\r
final Palette<String> indexedBranchesPalette = new Palette<String>("indexedBranches", new ListModel<String>(\r
indexedBranches), new CollectionModel<String>(allLocalBranches),\r
new StringChoiceRenderer(), 8, false);\r
- indexedBranchesPalette.setEnabled(luceneEnabled && (allLocalBranches.size() > 0));\r
+ indexedBranchesPalette.setEnabled(luceneEnabled);\r
\r
// federation sets palette\r
List<String> sets = GitBlit.getStrings(Keys.federation.sets);\r