Skip to content

Commit 4eabfa9

Browse files
committed
[update-checkout] Fetch if the local branch/tag doesn't exist
Dependencies are usually updated to a different branch/tag name when new versions get new released, but local checkout might not have that fetched yet, so if initial checkout fails, let's fetch before attempting to checkout.
1 parent 2e4a010 commit 4eabfa9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

utils/update_checkout/update_checkout/update_checkout.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ def update_single_repository(pool_args):
156156
if checkout_target:
157157
shell.run(['git', 'status', '--porcelain', '-uno'],
158158
echo=False)
159+
160+
# Some of the projects switch branches/tags when they
161+
# are updated. Local checkout might not have that tag/branch
162+
# fetched yet, so let's attempt to fetch before attempting
163+
# checkout.
164+
try:
165+
shell.run(['git', 'rev-parse', '--verify', checkout_target])
166+
except Exception:
167+
shell.run(["git", "fetch", "--recurse-submodules=yes",
168+
"--tags"],
169+
echo=True)
170+
159171
try:
160172
shell.run(['git', 'checkout', checkout_target], echo=True)
161173
except Exception as originalException:

0 commit comments

Comments
 (0)