From b674278ce71b2ee683b8b0c98c9a64152988ecdb Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Wed, 19 Jan 2022 21:10:16 +0000 Subject: [PATCH] Always fetch main in update_depot_tools If main is not fetchable, report the error to end user. R=gavinmak@google.com Bug: 1277136 Change-Id: I8c061719f9aadc42786045b3c5331bab3d0caae7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3389824 Reviewed-by: Gavin Mak Commit-Queue: Josip Sokcevic --- update_depot_tools | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/update_depot_tools b/update_depot_tools index d15ca563cc..93ce22ebfa 100755 --- a/update_depot_tools +++ b/update_depot_tools @@ -99,18 +99,20 @@ function update_git_repo { fi fi - # depot_tools.zip archives generated before 2021-03-12 have instruction to - # fetch only from old default git branch. Such branch won't be available - # evenutally, so fetch config needs to be updated. - git config --unset-all remote.origin.fetch - git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* - git fetch -q origin &> /dev/null - local CHECKOUT_TXT STATUS - CHECKOUT_TXT=$(git checkout -q origin/main 2>&1) + local GIT_CMD_TXT STATUS + GIT_CMD_TXT=$(git fetch -q origin main 2>&1) STATUS=$? if [[ $STATUS -ne 0 ]]; then - echo "depot_tools update failed. Conflict in $base_dir" >&2 - echo "$CHECKOUT_TXT" >&2 + echo "depot_tools update failed. Couldn't fetch main branch." + echo "Retry later or reclone depot_tools" >&2 + echo "$GIT_CMD_TXT" >&2 + else + GIT_CMD_TXT=$(git checkout -q origin/main 2>&1) + STATUS=$? + if [[ $STATUS -ne 0 ]]; then + echo "depot_tools update failed. Conflict in $base_dir" >&2 + echo "$GIT_CMD_TXT" >&2 + fi fi # Having python3 on depot_tools causes problems if users put depot_tools in # PATH before system's python3, so remove it if present.