Jelajahi Sumber

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 <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Josip Sokcevic 3 tahun lalu
induk
melakukan
b674278ce7
1 mengubah file dengan 12 tambahan dan 10 penghapusan
  1. 12 10
      update_depot_tools

+ 12 - 10
update_depot_tools

@@ -99,18 +99,20 @@ function update_git_repo {
     fi
     fi
   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=$?
   STATUS=$?
   if [[ $STATUS -ne 0 ]]; then
   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
   fi
   # Having python3 on depot_tools causes problems if users put depot_tools in
   # Having python3 on depot_tools causes problems if users put depot_tools in
   # PATH before system's python3, so remove it if present.
   # PATH before system's python3, so remove it if present.