blob: c6ad44802e5b6475cc425789e5a0aac9c8a06ed7 [file] [log] [blame]
Sam Judd0b987d22014-10-24 10:43:35 -07001#!/bin/bash -e
Alan Newberger9d4d0642014-12-03 10:58:55 -08002# 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
Sam Judd0b987d22014-10-24 10:43:35 -07004# directories, scripts, and build files.
5#
Sam Judd0b987d22014-10-24 10:43:35 -07006# 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
Alan Newberger9d4d0642014-12-03 10:58:55 -080011ANDROID_BRANCH_NAME=$(repo info . | sed -n 's/Current revision: \(.*\)/\1/p')
Sam Judd0b987d22014-10-24 10:43:35 -070012
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
Alan Newberger9d4d0642014-12-03 10:58:55 -080036# Switch to the branch in Android we want to update, sync and merge.
Sam Judd0b987d22014-10-24 10:43:35 -070037git checkout ${ANDROID_BRANCH_NAME}
Alan Newberger9d4d0642014-12-03 10:58:55 -080038repo sync .
39# FETCH_HEAD defined by the fetch of the tag/branch above
40git merge FETCH_HEAD || true
Sam Judd0b987d22014-10-24 10:43:35 -070041
Alan Newberger9d4d0642014-12-03 10:58:55 -080042# Remove source/build directories we don't care about.
Sam Judd0b987d22014-10-24 10:43:35 -070043git rm -rf samples || true
44git rm -rf integration || true
45git rm -rf static || true
46git rm -rf glide || true
Alan Newberger9d4d0642014-12-03 10:58:55 -080047git rm -rf .idea || true
Sam Judd0b987d22014-10-24 10:43:35 -070048
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.
Alan Newberger9d4d0642014-12-03 10:58:55 -080073find . -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
Sam Judd0b987d22014-10-24 10:43:35 -070078
Alan Newberger9d4d0642014-12-03 10:58:55 -080079# 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}"
Sam Judd0b987d22014-10-24 10:43:35 -070082echo "Now fix any merge conflicts, commit, and run: git push goog ${ANDROID_BRANCH_NAME}"