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