benjaminwagner | 787ca87 | 2015-08-17 12:58:10 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2014 Google Inc. |
| 3 | # |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # Crude script to clone the git skia repo into the current directory, which |
| 8 | # must be a CitC client. |
| 9 | # |
| 10 | # Usage: |
| 11 | # ./tools/git_clone_to_google3.sh |
| 12 | |
benjaminwagner | 964eeba | 2015-10-20 13:00:48 -0700 | [diff] [blame] | 13 | prodcertstatus -q || (echo "Please run prodaccess." 1>&2; exit 1) |
| 14 | source gbash.sh || exit 2 |
| 15 | |
benjaminwagner | 787ca87 | 2015-08-17 12:58:10 -0700 | [diff] [blame] | 16 | DEFINE_string skia_rev "" "Git hash of Skia revision to clone, default LKGR." |
benjaminwagner | f82c13f | 2015-08-18 06:25:14 -0700 | [diff] [blame] | 17 | gbash::init_google "$@" |
benjaminwagner | 787ca87 | 2015-08-17 12:58:10 -0700 | [diff] [blame] | 18 | |
benjaminwagner | 964eeba | 2015-10-20 13:00:48 -0700 | [diff] [blame] | 19 | set -e |
benjaminwagner | 787ca87 | 2015-08-17 12:58:10 -0700 | [diff] [blame] | 20 | |
| 21 | # Checkout LKGR of Skia in a temp location. |
| 22 | TMP=$(gbash::make_temp_dir) |
| 23 | pushd "${TMP}" |
| 24 | git clone https://skia.googlesource.com/skia |
| 25 | cd skia |
| 26 | git fetch |
| 27 | if [ -z "${FLAGS_skia_rev}" ]; then |
| 28 | # Retrieve last known good revision. |
| 29 | MY_DIR="$(gbash::get_absolute_caller_dir)" |
| 30 | FLAGS_skia_rev="$(${MY_DIR}/get_skia_lkgr.sh)" |
| 31 | fi |
| 32 | git checkout --detach "${FLAGS_skia_rev}" |
| 33 | |
| 34 | # Rsync to google3 location. |
| 35 | popd |
| 36 | # Use multichange client in case there are too many files for nomultichange. http://b/7292343 |
| 37 | g4 client --set_option multichange |
| 38 | # Use allwrite to simplify opening the correct files after rsync. |
| 39 | g4 client --set_option allwrite |
| 40 | # Filter directories added to CitC. |
| 41 | rsync -avzJ \ |
| 42 | --delete \ |
| 43 | --delete-excluded \ |
| 44 | --include=/bench \ |
| 45 | --include=/dm \ |
| 46 | --include=/gm \ |
| 47 | --include=/include \ |
benjaminwagner | 964eeba | 2015-10-20 13:00:48 -0700 | [diff] [blame] | 48 | --include=/resources \ |
benjaminwagner | e349d6b | 2015-08-17 14:44:01 -0700 | [diff] [blame] | 49 | --exclude=/src/animator \ |
benjaminwagner | f82c13f | 2015-08-18 06:25:14 -0700 | [diff] [blame] | 50 | --include=/src \ |
benjaminwagner | 787ca87 | 2015-08-17 12:58:10 -0700 | [diff] [blame] | 51 | --include=/tests \ |
| 52 | --include=/third_party \ |
| 53 | --include=/tools \ |
| 54 | --include=/.git \ |
| 55 | '--exclude=/*/' \ |
| 56 | --include=/third_party/etc1 \ |
| 57 | --include=/third_party/ktx \ |
| 58 | --include=/third_party/libwebp \ |
| 59 | '--exclude=/third_party/*/' \ |
| 60 | "${TMP}/skia/" \ |
| 61 | "./" |
| 62 | |
| 63 | # Open added/changed files for add/edit. |
| 64 | g4 reopen |
| 65 | # Revert files that are equivalent to the checked in version. |
| 66 | g4 revert -a |
| 67 | |
| 68 | # Tell CitC to ignore .git and .gitignore. |
| 69 | find . \ |
| 70 | \( -name .git \ |
| 71 | -o -name .gitignore \ |
| 72 | \) \ |
| 73 | -execdir g4 revert -k \{\} \; |
| 74 | |
| 75 | # Tell Git to ignore README.google and BUILD. |
| 76 | echo README.google >> .git/info/exclude |
| 77 | echo BUILD >> .git/info/exclude |
| 78 | g4 revert README.google |
| 79 | g4 revert BUILD |
| 80 | |
benjaminwagner | f82c13f | 2015-08-18 06:25:14 -0700 | [diff] [blame] | 81 | # Use google3 version of OWNERS. |
benjaminwagner | 787ca87 | 2015-08-17 12:58:10 -0700 | [diff] [blame] | 82 | find . \ |
benjaminwagner | f82c13f | 2015-08-18 06:25:14 -0700 | [diff] [blame] | 83 | -name OWNERS \ |
benjaminwagner | 787ca87 | 2015-08-17 12:58:10 -0700 | [diff] [blame] | 84 | -exec git update-index --skip-worktree \{\} \; \ |
| 85 | -execdir g4 revert \{\} \; |
| 86 | |
benjaminwagner | f82c13f | 2015-08-18 06:25:14 -0700 | [diff] [blame] | 87 | # Tell git to ignore these files that have Windows line endings, because Piper |
| 88 | # will always change them to Unix line endings. |
| 89 | git update-index --skip-worktree make.bat |
| 90 | git update-index --skip-worktree make.py |
| 91 | |
benjaminwagner | 787ca87 | 2015-08-17 12:58:10 -0700 | [diff] [blame] | 92 | # Tell git to ignore files left out of the rsync (i.e. "deleted" files). |
| 93 | git status --porcelain | \ |
| 94 | grep -e "^ D" | \ |
| 95 | cut -c 4- | \ |
| 96 | xargs git update-index --skip-worktree |
| 97 | |