roll_deps.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021 Google LLC
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # Attempts to roll all entries in DEPS to tip-of-tree and create a commit.
  16. #
  17. # Depends on roll-dep from depot_tools
  18. # (https://chromium.googlesource.com/chromium/tools/depot_tools) being in PATH.
  19. set -eo pipefail
  20. function ExitIfIsInterestingError() {
  21. local return_code=$1
  22. if [[ ${return_code} -ne 0 && ${return_code} -ne 2 ]]; then
  23. exit ${return_code}
  24. fi
  25. return 0
  26. }
  27. declare -A dependency_to_branch_map
  28. dependency_to_branch_map["external/abseil_cpp"]="origin/master"
  29. dependency_to_branch_map["external/effcee/"]="origin/main"
  30. dependency_to_branch_map["external/googletest/"]="origin/main"
  31. dependency_to_branch_map["external/re2/"]="origin/main"
  32. dependency_to_branch_map["external/spirv-headers/"]="origin/main"
  33. # This script assumes it's parent directory is the repo root.
  34. repo_path=$(dirname "$0")/..
  35. cd "$repo_path"
  36. if [[ $(git diff --stat) != '' ]]; then
  37. echo "Working tree is dirty, commit changes before attempting to roll DEPS"
  38. exit 1
  39. fi
  40. echo "*** Ignore messages about running 'git cl upload' ***"
  41. old_head=$(git rev-parse HEAD)
  42. set +e
  43. for dep in ${!dependency_to_branch_map[@]}; do
  44. branch=${dependency_to_branch_map[$dep]}
  45. echo "Rolling $dep"
  46. roll-dep --ignore-dirty-tree --roll-to="${branch}" "${dep}"
  47. ExitIfIsInterestingError $?
  48. done