1#!/bin/bash 2# 3# Copyright 2023 The Android Open Source Project. 4# 5# Retrieves the current mockito-kotlin source code into the current directory 6 7# Force stop on first error. 8set -e 9 10if [ $# -ne 1 ]; then 11 echo "$0 <version>" >&2 12 exit 1; 13fi 14 15if [ -z "$ANDROID_BUILD_TOP" ]; then 16 echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" >&2 17 exit 1 18fi 19 20VERSION=${1} 21 22SOURCE="git://github.com/mockito/mockito-kotlin.git" 23INCLUDE=" 24 LICENSE 25 mockito-kotlin/src/main 26 " 27 28working_dir="$(mktemp -d)" 29trap "echo \"Removing temporary directory\"; rm -rf $working_dir" EXIT 30 31echo "Fetching mockito-kotlin source into $working_dir" 32git clone $SOURCE $working_dir/source 33(cd $working_dir/source; git checkout $VERSION) 34 35for include in ${INCLUDE}; do 36 echo "Updating $include" 37 rm -rf $include 38 mkdir -p $(dirname $include) 39 cp -R $working_dir/source/$include $include 40done; 41 42echo "Done" 43 44# Update the version. 45perl -pi -e "s|^Version: .*$|Version: ${VERSION}|" "README.version" 46 47# Remove any documentation about local modifications. 48mv README.version README.tmp 49grep -B 100 "Local Modifications" README.tmp > README.version 50echo " None" >> README.version 51rm README.tmp 52 53echo "Done" 54