blob: 9f64fc75144a37198f91cb01c67010ddf02f9ce0 [file] [log] [blame]
benjaminwagner787ca872015-08-17 12:58:10 -07001#!/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
benjaminwagner964eeba2015-10-20 13:00:48 -070013prodcertstatus -q || (echo "Please run prodaccess." 1>&2; exit 1)
14source gbash.sh || exit 2
15
benjaminwagner787ca872015-08-17 12:58:10 -070016DEFINE_string skia_rev "" "Git hash of Skia revision to clone, default LKGR."
benjaminwagnerf82c13f2015-08-18 06:25:14 -070017gbash::init_google "$@"
benjaminwagner787ca872015-08-17 12:58:10 -070018
benjaminwagner964eeba2015-10-20 13:00:48 -070019set -e
benjaminwagner787ca872015-08-17 12:58:10 -070020
21# Checkout LKGR of Skia in a temp location.
22TMP=$(gbash::make_temp_dir)
23pushd "${TMP}"
24git clone https://skia.googlesource.com/skia
25cd skia
26git fetch
27if [ -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)"
31fi
32git checkout --detach "${FLAGS_skia_rev}"
33
34# Rsync to google3 location.
35popd
36# Use multichange client in case there are too many files for nomultichange. http://b/7292343
37g4 client --set_option multichange
38# Use allwrite to simplify opening the correct files after rsync.
39g4 client --set_option allwrite
40# Filter directories added to CitC.
41rsync -avzJ \
42 --delete \
43 --delete-excluded \
44 --include=/bench \
45 --include=/dm \
46 --include=/gm \
47 --include=/include \
benjaminwagner964eeba2015-10-20 13:00:48 -070048 --include=/resources \
benjaminwagnere349d6b2015-08-17 14:44:01 -070049 --exclude=/src/animator \
benjaminwagnerf82c13f2015-08-18 06:25:14 -070050 --include=/src \
benjaminwagner787ca872015-08-17 12:58:10 -070051 --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.
64g4 reopen
65# Revert files that are equivalent to the checked in version.
66g4 revert -a
67
68# Tell CitC to ignore .git and .gitignore.
69find . \
70 \( -name .git \
71 -o -name .gitignore \
72 \) \
73 -execdir g4 revert -k \{\} \;
74
75# Tell Git to ignore README.google and BUILD.
76echo README.google >> .git/info/exclude
77echo BUILD >> .git/info/exclude
78g4 revert README.google
79g4 revert BUILD
80
benjaminwagnerf82c13f2015-08-18 06:25:14 -070081# Use google3 version of OWNERS.
benjaminwagner787ca872015-08-17 12:58:10 -070082find . \
benjaminwagnerf82c13f2015-08-18 06:25:14 -070083 -name OWNERS \
benjaminwagner787ca872015-08-17 12:58:10 -070084 -exec git update-index --skip-worktree \{\} \; \
85 -execdir g4 revert \{\} \;
86
benjaminwagnerf82c13f2015-08-18 06:25:14 -070087# Tell git to ignore these files that have Windows line endings, because Piper
88# will always change them to Unix line endings.
89git update-index --skip-worktree make.bat
90git update-index --skip-worktree make.py
91
benjaminwagner787ca872015-08-17 12:58:10 -070092# Tell git to ignore files left out of the rsync (i.e. "deleted" files).
93git status --porcelain | \
94 grep -e "^ D" | \
95 cut -c 4- | \
96 xargs git update-index --skip-worktree
97