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