import com.beust.jcommander.Parameter;\r
import com.beust.jcommander.ParameterException;\r
import com.beust.jcommander.Parameters;\r
+import com.gitblit.models.RefModel;\r
import com.gitblit.utils.ArrayUtils;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.utils.StringUtils;\r
continue;\r
}\r
\r
- System.out.println(MessageFormat.format("adding [gitblit] indexBranch={0} for {1}", params.branch, repo));\r
+ \r
try {\r
// load repository config\r
File gitDir = FileKey.resolve(new File(folder, repo), FS.DETECTED);\r
config.load();\r
\r
Set<String> indexedBranches = new LinkedHashSet<String>();\r
- indexedBranches.add(params.branch);\r
+ \r
+ // add all local branches to index\r
+ if(params.addAllLocalBranches) {\r
+ List<RefModel> list = JGitUtils.getLocalBranches(repository, true, -1);\r
+ for (RefModel refModel : list) {\r
+ System.out.println(MessageFormat.format("adding [gitblit] indexBranch={0} for {1}", refModel.getName(), repo));\r
+ indexedBranches.add(refModel.getName());\r
+ }\r
+ }\r
+ else {\r
+ // add only one branch to index ('default' if not specified)\r
+ System.out.println(MessageFormat.format("adding [gitblit] indexBranch={0} for {1}", params.branch, repo));\r
+ indexedBranches.add(params.branch);\r
+ }\r
\r
String [] branches = config.getStringList("gitblit", null, "indexBranch");\r
if (!ArrayUtils.isEmpty(branches)) {\r
@Parameter(names = { "--repositoriesFolder" }, description = "The root repositories folder ", required = true)\r
public String folder;\r
\r
- @Parameter(names = { "--branch" }, description = "The branch to index", required = true)\r
+ @Parameter(names = { "--branch" }, description = "The branch to index", required = false)\r
public String branch = "default";\r
\r
@Parameter(names = { "--skip" }, description = "Skip the named repository (simple fizzy matching is supported)", required = false)\r
public List<String> exclusions = new ArrayList<String>();\r
+ \r
+ @Parameter(names = { "--all-local-branches" }, description = "Add all local branches to index. If specified, the --branch parameter is not considered.", required = false)\r
+ public boolean addAllLocalBranches = false;\r
}\r
}\r