Skip to content

Commit aba448e

Browse files
authored
Merge pull request #40823 from xedin/fix-update-checkout
[update-checkout] Fetch if the local branch/tag doesn't exist
2 parents 8ef5e9e + 4eabfa9 commit aba448e

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)