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