RepoUpdater: allow to set recordRemoteBranch via config

The RepoCommand has a recordRemoteBranch option, but it is not read
from the configuration (it is always set to true). The "branch"
attribute controls also the autoupdate of submodules and in some
branches we want to disable that.

Read the value from the conf and pass it to the RepoUpdater. Default
to true to keep the current behavior.

Change-Id: I728853f69bf3c21c882b3eae17e4eeb7b2cc3621
diff --git a/java/com/googlesource/gerrit/plugins/supermanifest/ConfigEntry.java b/java/com/googlesource/gerrit/plugins/supermanifest/ConfigEntry.java
index 0beaff2..be8e474 100644
--- a/java/com/googlesource/gerrit/plugins/supermanifest/ConfigEntry.java
+++ b/java/com/googlesource/gerrit/plugins/supermanifest/ConfigEntry.java
@@ -43,6 +43,7 @@
   final Project.NameKey destRepoKey;
   final String repoGroups;
   final ImmutableSet<String> srcRefsExcluded;
+  final boolean recordRemoteBranch;
   final boolean recordSubmoduleLabels;
   final boolean ignoreRemoteFailures;
 
@@ -126,6 +127,7 @@
     destBranch = destRef.substring(REFS_HEADS.length());
 
     repoGroups = nullToEmpty(cfg.getString(SECTION_NAME, name, "groups"));
+    recordRemoteBranch = cfg.getBoolean(SECTION_NAME, name, "recordRemoteBranch", true);
     recordSubmoduleLabels = cfg.getBoolean(SECTION_NAME, name, "recordSubmoduleLabels", false);
     ignoreRemoteFailures = cfg.getBoolean(SECTION_NAME, name, "ignoreRemoteFailures", false);
 
diff --git a/java/com/googlesource/gerrit/plugins/supermanifest/RepoUpdater.java b/java/com/googlesource/gerrit/plugins/supermanifest/RepoUpdater.java
index c888d57..ac49909 100644
--- a/java/com/googlesource/gerrit/plugins/supermanifest/RepoUpdater.java
+++ b/java/com/googlesource/gerrit/plugins/supermanifest/RepoUpdater.java
@@ -50,7 +50,7 @@
 
     cmd.setAuthor(serverIdent)
         .setGroups(c.getGroupsParameter())
-        .setRecordRemoteBranch(true)
+        .setRecordRemoteBranch(c.recordRemoteBranch)
         .setRecordSubmoduleLabels(c.isRecordSubmoduleLabels())
         .setIgnoreRemoteFailures(c.ignoreRemoteFailures)
         .setInputStream(manifestStream)
diff --git a/javatests/com/googlesource/gerrit/plugins/supermanifest/ConfigEntryTest.java b/javatests/com/googlesource/gerrit/plugins/supermanifest/ConfigEntryTest.java
index 80193e6..080918d 100644
--- a/javatests/com/googlesource/gerrit/plugins/supermanifest/ConfigEntryTest.java
+++ b/javatests/com/googlesource/gerrit/plugins/supermanifest/ConfigEntryTest.java
@@ -216,6 +216,25 @@
   }
 
   @Test
+  public void recordRemoteBranch() throws ConfigInvalidException {
+    StringBuilder builder =
+        new StringBuilder(
+            getBasicConf(
+                "superproject",
+                "refs/heads/nyc",
+                "manifest",
+                "refs/heads/nyc-src",
+                "default.xml"))
+            .append("  recordRemoteBranch = false\n");
+    Config cfg = new Config();
+    cfg.fromText(builder.toString());
+
+    ConfigEntry entry = new ConfigEntry(cfg, "superproject:refs/heads/nyc");
+
+    assertThat(entry.recordRemoteBranch).isFalse();
+  }
+
+  @Test
   public void matchesSource() throws ConfigInvalidException {
     StringBuilder builder =
         new StringBuilder(