Update default repo branches when checking out
Change-Id: Ic706c2720748b33e9d3e1c279f007a1bc7565546
Bug: https://github.com/flutter/flutter/issues/105239
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/30880
Reviewed-by: Stuart Morgan <stuartmorgan@google.com>
diff --git a/recipe_modules/repo_util/api.py b/recipe_modules/repo_util/api.py
index 97f4da6..2f93d16 100644
--- a/recipe_modules/repo_util/api.py
+++ b/recipe_modules/repo_util/api.py
@@ -17,6 +17,16 @@
'https://flutter.googlesource.com/mirrors/plugins'
}
+# TODO(keyonghan): deprecate when all repos are migrated to main.
+REPO_BRANCHES = {
+ 'flutter': 'master',
+ 'engine': 'main',
+ 'cocoon': 'main',
+ 'infra': 'main',
+ 'packages': 'main',
+ 'plugins': 'main'
+}
+
import re
from recipe_engine import recipe_api
@@ -72,7 +82,7 @@
soln.custom_vars = custom_vars
src_cfg.parent_got_revision_mapping['parent_got_revision'
] = 'got_revision'
- src_cfg.repo_path_map[git_url] = ('src/flutter', git_ref or 'refs/heads/master')
+ src_cfg.repo_path_map[git_url] = ('src/flutter', git_ref or 'refs/heads/%s' % REPO_BRANCHES['engine'])
self.m.gclient.c = src_cfg
self.m.gclient.c.got_revision_mapping['src/flutter'
] = 'got_engine_revision'
@@ -104,13 +114,13 @@
# gitiles_commit.id is more specific than gitiles_commit.ref, which is
# branch
# if this a release build, self.m.buildbucket.gitiles_commit.id should have more priority than
- # ref since it is more specific, and we don't want to default to refs/heads/master
+ # ref since it is more specific, and we don't want to default to refs/heads/<REPO_BRANCHES[name]>
if ref in ['refs/heads/beta', 'refs/heads/stable']:
git_ref = (self.m.buildbucket.gitiles_commit.id or
self.m.buildbucket.gitiles_commit.ref or ref)
else:
git_ref = (ref or self.m.buildbucket.gitiles_commit.id or
- self.m.buildbucket.gitiles_commit.ref or 'refs/heads/master')
+ self.m.buildbucket.gitiles_commit.ref or 'refs/heads/%s' % REPO_BRANCHES[name])
def do_checkout():
return self.m.git.checkout(
diff --git a/recipe_modules/repo_util/examples/full.expected/first_bot_update_failed.json b/recipe_modules/repo_util/examples/full.expected/first_bot_update_failed.json
index 8d6cb23..19e5c68 100644
--- a/recipe_modules/repo_util/examples/full.expected/first_bot_update_failed.json
+++ b/recipe_modules/repo_util/examples/full.expected/first_bot_update_failed.json
@@ -808,7 +808,7 @@
"Traceback (most recent call last):",
" File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/examples/full.py\", line 29, in RunSteps",
" api.repo_util.engine_checkout(api.path['start_dir'].join('engine'), {}, {})",
- " File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/api.py\", line 86, in engine_checkout",
+ " File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/api.py\", line 96, in engine_checkout",
" self.m.retry.wrap(_InnerCheckout, step_name='Checkout source', sleep=10.0, backoff_factor=5, max_attempts=4)",
" File \"RECIPE_REPO[flutter]/recipe_modules/retry/api.py\", line 88, in wrap",
" step = self.m.step.active_result",
diff --git a/recipe_modules/repo_util/examples/unsupported.expected/unsupported.json b/recipe_modules/repo_util/examples/unsupported.expected/unsupported.json
index 5f5f2da..6d8af43 100644
--- a/recipe_modules/repo_util/examples/unsupported.expected/unsupported.json
+++ b/recipe_modules/repo_util/examples/unsupported.expected/unsupported.json
@@ -9,7 +9,7 @@
"Traceback (most recent call last):",
" File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/examples/unsupported.py\", line 15, in RunSteps",
" api.repo_util.checkout('unsupported_repo', repo_dir)",
- " File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/api.py\", line 101, in checkout",
+ " File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/api.py\", line 111, in checkout",
" raise ValueError('Unsupported repo: %s' % name)",
"ValueError('Unsupported repo: unsupported_repo')"
]
diff --git a/recipes/packages/packages.expected/master_channel.json b/recipes/packages/packages.expected/master_channel.json
index 0c896bf..3b35a45 100644
--- a/recipes/packages/packages.expected/master_channel.json
+++ b/recipes/packages/packages.expected/master_channel.json
@@ -30,7 +30,7 @@
"git",
"fetch",
"origin",
- "master",
+ "main",
"--recurse-submodules",
"--progress",
"--tags"
diff --git a/recipes/packages/packages.expected/stable_channel.json b/recipes/packages/packages.expected/stable_channel.json
index 697ca6c..ecdb822 100644
--- a/recipes/packages/packages.expected/stable_channel.json
+++ b/recipes/packages/packages.expected/stable_channel.json
@@ -30,7 +30,7 @@
"git",
"fetch",
"origin",
- "master",
+ "main",
"--recurse-submodules",
"--progress",
"--tags"
diff --git a/recipes/plugins/plugins.expected/master_channel.json b/recipes/plugins/plugins.expected/master_channel.json
index dff34b3..0eb8092 100644
--- a/recipes/plugins/plugins.expected/master_channel.json
+++ b/recipes/plugins/plugins.expected/master_channel.json
@@ -30,7 +30,7 @@
"git",
"fetch",
"origin",
- "master",
+ "main",
"--recurse-submodules",
"--progress",
"--tags"
diff --git a/recipes/plugins/plugins.expected/stable_channel.json b/recipes/plugins/plugins.expected/stable_channel.json
index 763120e..cfa548c 100644
--- a/recipes/plugins/plugins.expected/stable_channel.json
+++ b/recipes/plugins/plugins.expected/stable_channel.json
@@ -30,7 +30,7 @@
"git",
"fetch",
"origin",
- "master",
+ "main",
"--recurse-submodules",
"--progress",
"--tags"