Commit 6651fd88 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

Use HEAD instead of hardcoded branch

Repositories may have different default branches. This ensures to fetch
remote HEAD branch which is default branch. Only downside to this
approach is that actual branch (e.g. origin/main) reference won't be
updated. Since we don't need it for this particular case, it should be
fine to use HEAD.

R=apolito@google.com, ehmaldonaldo@chromium.org

Bug: 1155492
Recipe-Nontrivial-Roll: chromiumos
Recipe-Nontrivial-Roll: infra
Recipe-Nontrivial-Roll: build_limited_scripts_slave
Change-Id: Ib2e6e50901a0a10ed647acea3aeb517b83567702
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2580190Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
parent 8732c0ef
......@@ -534,7 +534,7 @@ upload.
Args:
* branch (str): new branch name, which must not yet exist.
* name (str): step name.
* upstream (str): to origin/master.
* upstream (str): to origin/main.
* kwargs: Forwarded to '__call__'.
&mdash; **def [rebase](/recipes/recipe_modules/git/api.py#328)(self, name_prefix, branch, dir_path, remote_name=None, \*\*kwargs):**
......
......@@ -211,16 +211,16 @@ class GitApi(recipe_api.RecipeApi):
# There are five kinds of refs we can be handed:
# 0) None. In this case, we default to api.buildbucket.gitiles_commit.ref.
# 1) A fully qualified branch name, e.g. 'refs/heads/master'.
# 1) A fully qualified branch name, e.g. 'refs/heads/main'.
# Chop off 'refs/heads/' and now it matches case (4).
# 2) A 40-character SHA1 hash.
# 3) A fully-qualifed arbitrary ref, e.g. 'refs/foo/bar/baz'.
# 4) A branch name, e.g. 'master'.
# 4) A branch name, e.g. 'main'.
# Note that 'FETCH_HEAD' can be many things (and therefore not a valid
# checkout target) if many refs are fetched, but we only explicitly fetch
# one ref here, so this is safe.
if not ref: # Case 0.
ref = self.m.buildbucket.gitiles_commit.ref or 'master'
ref = self.m.buildbucket.gitiles_commit.ref or 'HEAD'
# If it's a fully-qualified branch name, trim the 'refs/heads/' prefix.
if ref.startswith('refs/heads/'): # Case 1.
......@@ -396,7 +396,7 @@ class GitApi(recipe_api.RecipeApi):
Args:
* branch (str): new branch name, which must not yet exist.
* name (str): step name.
* upstream (str): to origin/master.
* upstream (str): to origin/main.
* kwargs: Forwarded to '__call__'.
"""
env = self.m.context.env
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress",
"--tags"
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -37,7 +37,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -64,7 +64,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -18,7 +18,7 @@
"git",
"fetch",
"not_origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
......@@ -16,7 +16,7 @@
"git",
"fetch",
"origin",
"master",
"HEAD",
"--recurse-submodules",
"--progress"
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment