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 16# Attempts to roll all entries in DEPS to tip-of-tree and create a commit. 17# 18# Depends on roll-dep from depot_tools 19# (https://chromium.googlesource.com/chromium/tools/depot_tools) being in PATH. 20 21set -eo pipefail 22 23function ExitIfIsInterestingError() { 24 local return_code=$1 25 if [[ ${return_code} -ne 0 && ${return_code} -ne 2 ]]; then 26 exit ${return_code} 27 fi 28 return 0 29} 30 31 32declare -A dependency_to_branch_map 33dependency_to_branch_map["external/abseil_cpp"]="origin/master" 34dependency_to_branch_map["external/effcee/"]="origin/main" 35dependency_to_branch_map["external/googletest/"]="origin/main" 36dependency_to_branch_map["external/re2/"]="origin/main" 37dependency_to_branch_map["external/spirv-headers/"]="origin/main" 38 39# This script assumes it's parent directory is the repo root. 40repo_path=$(dirname "$0")/.. 41 42cd "$repo_path" 43 44if [[ $(git diff --stat) != '' ]]; then 45 echo "Working tree is dirty, commit changes before attempting to roll DEPS" 46 exit 1 47fi 48 49echo "*** Ignore messages about running 'git cl upload' ***" 50 51old_head=$(git rev-parse HEAD) 52 53set +e 54 55for dep in ${!dependency_to_branch_map[@]}; do 56 branch=${dependency_to_branch_map[$dep]} 57 echo "Rolling $dep" 58 roll-dep --ignore-dirty-tree --roll-to="${branch}" "${dep}" 59 ExitIfIsInterestingError $? 60done 61