metadata.json: Set a value for 'branch'.

Set a default metadata value for the branch we are building.

BUG=chromium:407876
TEST=None

Change-Id: I6aed42024a9d8602755d512891af5919fcf5ed21
Reviewed-on: https://chromium-review.googlesource.com/894844
Commit-Ready: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Ningning Xia <nxia@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index c7b0191..a8f0230 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -140,11 +140,6 @@
     # Create directory if in need
     osutils.SafeMakedirsNonRoot(options.chrome_root)
 
-  metadata_dump_dict = {}
-  if options.metadata_dump:
-    with open(options.metadata_dump, 'r') as metadata_file:
-      metadata_dump_dict = json.loads(metadata_file.read())
-
   # We are done munging options values, so freeze options object now to avoid
   # further abuse of it.
   # TODO(mtennant): one by one identify each options value override and see if
@@ -152,6 +147,14 @@
   # to the start of the script (e.g. in or after _PostParseCheck).
   options.Freeze()
 
+  metadata_dump_dict = {
+      # A detected default has been set before now if it wasn't explicit.
+      'branch': options.branch,
+  }
+  if options.metadata_dump:
+    with open(options.metadata_dump, 'r') as metadata_file:
+      metadata_dump_dict = json.loads(metadata_file.read())
+
   with parallel.Manager() as manager:
     builder_run = cbuildbot_run.BuilderRun(
         options, site_config, build_config, manager)