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