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