Allow specifying which groups to subscribe to
JGit's RepoCommand defaults to tracking groups all,-notdefault. Most
users of this plugin are likely to want to track all groups instead,
so provide a knob to allow requesting that.
If the value `all` proves overwhelmingly popular in practice, then it
can be made the default in JGit and this setting could be removed.
Change-Id: Ibddb5fdbaa9d57e6bce12affd39e14c73ee481e5
Reported-by: Jeff Gaston <jeffrygaston@google.com>
diff --git a/java/Documentation/about.md b/java/Documentation/about.md
index 4de2ad3..b392dbf 100644
--- a/java/Documentation/about.md
+++ b/java/Documentation/about.md
@@ -38,6 +38,9 @@
The plugin supports the following options:
+* `groups` (defaults to `default`). Sets the groups setting for JGit's
+ RepoCommand
+
* `recordSubmoduleLabels` (defaults to false). Sets recordSubmoduleLabels
setting for JGit's RepoCommand
diff --git a/java/com/googlesource/gerrit/plugins/supermanifest/ConfigEntry.java b/java/com/googlesource/gerrit/plugins/supermanifest/ConfigEntry.java
index ad5e90d..85862fb 100644
--- a/java/com/googlesource/gerrit/plugins/supermanifest/ConfigEntry.java
+++ b/java/com/googlesource/gerrit/plugins/supermanifest/ConfigEntry.java
@@ -14,9 +14,9 @@
package com.googlesource.gerrit.plugins.supermanifest;
+import static com.google.common.base.Strings.nullToEmpty;
import static com.google.gerrit.reviewdb.client.RefNames.REFS_HEADS;
-import com.google.common.base.Strings;
import com.google.gerrit.reviewdb.client.Project;
import java.net.URI;
import java.net.URISyntaxException;
@@ -34,6 +34,7 @@
ToolType toolType;
String xmlPath;
Project.NameKey destRepoKey;
+ String repoGroups;
boolean recordSubmoduleLabels;
boolean ignoreRemoteFailures;
@@ -68,7 +69,7 @@
// TODO(hanwen): sanity check repo names.
srcRepoKey = new Project.NameKey(srcRepo);
- String toolType = Strings.nullToEmpty(cfg.getString(SECTION_NAME, name, "toolType"));
+ String toolType = nullToEmpty(cfg.getString(SECTION_NAME, name, "toolType"));
switch (toolType) {
case "":
@@ -110,6 +111,7 @@
// The external format is chosen so we can support copying over tags as well.
destBranch = destRef.substring(REFS_HEADS.length());
+ repoGroups = nullToEmpty(cfg.getString(SECTION_NAME, name, "groups"));
recordSubmoduleLabels = cfg.getBoolean(SECTION_NAME, name, "recordSubmoduleLabels", false);
ignoreRemoteFailures = cfg.getBoolean(SECTION_NAME, name, "ignoreRemoteFailures", false);
@@ -188,6 +190,11 @@
return recordSubmoduleLabels;
}
+ /** @return group restriction suitable for passing to {@code repo init -g} */
+ public String getGroupsParameter() {
+ return repoGroups;
+ }
+
/** @return the destBranch */
public String getDestBranch() {
return destBranch;
diff --git a/java/com/googlesource/gerrit/plugins/supermanifest/RepoUpdater.java b/java/com/googlesource/gerrit/plugins/supermanifest/RepoUpdater.java
index 094afe5..8edc7ba 100644
--- a/java/com/googlesource/gerrit/plugins/supermanifest/RepoUpdater.java
+++ b/java/com/googlesource/gerrit/plugins/supermanifest/RepoUpdater.java
@@ -52,6 +52,7 @@
new ByteArrayInputStream(Utils.readBlob(srcRepo, srcRef + ":" + c.getXmlPath()));
cmd.setAuthor(serverIdent)
+ .setGroups(c.getGroupsParameter())
.setRecordRemoteBranch(true)
.setRecordSubmoduleLabels(c.isRecordSubmoduleLabels())
.setIgnoreRemoteFailures(c.ignoreRemoteFailures)