1#!/bin/bash -e 2# Pulls down the version of Glide specified by tag/branch, merges it with 3# the existing local version of Glide, and removes unneeded tests, source 4# directories, scripts, and build files. 5# 6# Usage: ./update_files.sh [glide_brach_name|glide_tag_name|glide_commit] 7# 8# WARNING: This script will rm -rf files in the directory in 9# which it is run! 10 11ANDROID_BRANCH_NAME=$(repo info . | sed -n 's/Current revision: \(.*\)/\1/p') 12 13# Validate that we were given something to checkout from Glide's remote. 14if [ $# -ne 1 ] 15then 16 echo "Usage: ./update_files.sh [glide_brach_name|glide_tag_name|glide_commit]" 17 exit 1 18fi 19 20GLIDE_BRANCH=$1 21 22# We may have already added bump's remote. 23if ! git remote | grep bump > /dev/null; 24then 25 git remote add bump https://github.com/bumptech/glide.git 26fi 27 28# Validate that the thing we were given to checkout exists and fetch it if it 29# does. 30git fetch bump ${GLIDE_BRANCH} || exit 1 31 32# Remove the existing disk cache source so it doesn't conflict with Glide's 33# submodule. 34rm -rf third_party/disklrucache 35 36# Switch to the branch in Android we want to update, sync and merge. 37git checkout ${ANDROID_BRANCH_NAME} 38repo sync . 39# FETCH_HEAD defined by the fetch of the tag/branch above 40git merge FETCH_HEAD || true 41 42# Remove source/build directories we don't care about. 43git rm -rf samples || true 44git rm -rf integration || true 45git rm -rf static || true 46git rm -rf glide || true 47git rm -rf .idea || true 48 49# Remove test directories we don't care about. 50git rm -rf library/src/androidTest || true 51git rm -rf third_party/gif_decoder/src/androidTest || true 52git rm -rf third_party/gif_encoder/src/androidTest || true 53 54# Special case disklrucache because it's a submodule that we can't keep with 55# repo. 56git submodule deinit third_party/disklrucache 57git rm -rf third_party/disklrucache 58rm -rf third_party/disklrucache 59 60# Clone outside of the normal path to avoid conflicts with the submodule. 61REMOTE_DISK_PATH=third_party/remote_disklrucache 62git clone https://github.com/sjudd/disklrucache $REMOTE_DISK_PATH 63# Remove tests we don't care about. 64rm -rf $REMOTE_DISK_PATH/src/test 65# Remove git related things to avoid re-adding a submodule. 66rm -rf $REMOTE_DISK_PATH/.git 67rm -rf $REMOTE_DISK_PATH/.gitmodule 68# Copy the safe source only code back into the appropriate path. 69mv $REMOTE_DISK_PATH third_party/disklrucache 70git add third_party/disklrucache 71 72# Remove build/static analysis related files we don't care about. 73find . -name "*gradle*" | xargs -r git rm -rf 74find . -name "*checkstyle*.xml" | xargs -r git rm -rf 75find . -name "*pmd*.xml" | xargs -r git rm -rf 76find . -name "*findbugs*.xml" | xargs -r git rm -rf 77find . -name "*.iml" | xargs -r git rm -rf 78 79# FETCH_HEAD defined by the fetch of the tag/branch above 80GIT_SHA=$(git rev-parse FETCH_HEAD) 81echo "Merged bump ${GLIDE_BRANCH} at revision ${GIT_SHA}" 82echo "Now fix any merge conflicts, commit, and run: git push goog ${ANDROID_BRANCH_NAME}" 83