infra/recipes: Unshallow repo checkout few times as needed

Turns out `git fetch --unshallow` once can be insufficient in some
cases to move current checkout form grafted state. Use a loop to
unshallow it until it's not shallow.

TEST=led get-build 8797542734442160913 | led edit-recipe-bundle | led launch
BUG=b:240692674

Change-Id: If2dbe08f0e3341aefc42afee9db8e8b39efab56a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4026809
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
This commit is contained in:
Zihan Chen 2022-11-14 21:37:11 +00:00 committed by crosvm LUCI
parent e3d407f776
commit 50652dcd93

View file

@ -40,7 +40,11 @@ def RunSteps(api):
# Ignore errors from unshallow as repo sync sometimes resulted in full git history
api.crosvm.step_in_container(
"Unshallow crosvm", ["git", "fetch", "cros", "--unshallow"], cros=True, ok_ret="any"
"Unshallow crosvm as needed",
[
"for i in $(seq 1 5);do if [[ $(git rev-parse --is-shallow-repository) == 'true' ]]; then git fetch cros --unshallow; else break; fi; done"
],
cros=True,
)
api.crosvm.step_in_container("Print current git log", ["git", "log"], cros=True)