blob: 38d79e3c01cf4030b1b0432ea9d14c8dad87500a [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
13source gbash.sh || exit
14DEFINE_string skia_rev "" "Git hash of Skia revision to clone, default LKGR."
benjaminwagnerf82c13f2015-08-18 06:25:14 -070015gbash::init_google "$@"
benjaminwagner787ca872015-08-17 12:58:10 -070016
17set -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.
26TMP=$(gbash::make_temp_dir)
27pushd "${TMP}"
28git clone https://skia.googlesource.com/skia
29cd skia
30git fetch
31if [ -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)"
35fi
36git checkout --detach "${FLAGS_skia_rev}"
37
38# Rsync to google3 location.
39popd
40# Use multichange client in case there are too many files for nomultichange. http://b/7292343
41g4 client --set_option multichange
42# Use allwrite to simplify opening the correct files after rsync.
43g4 client --set_option allwrite
44# Filter directories added to CitC.
45rsync -avzJ \
46 --delete \
47 --delete-excluded \
48 --include=/bench \
49 --include=/dm \
50 --include=/gm \
51 --include=/include \
benjaminwagnere349d6b2015-08-17 14:44:01 -070052 --exclude=/src/animator \
benjaminwagnerf82c13f2015-08-18 06:25:14 -070053 --include=/src \
benjaminwagner787ca872015-08-17 12:58:10 -070054 --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.
67g4 reopen
68# Revert files that are equivalent to the checked in version.
69g4 revert -a
70
71# Tell CitC to ignore .git and .gitignore.
72find . \
73 \( -name .git \
74 -o -name .gitignore \
75 \) \
76 -execdir g4 revert -k \{\} \;
77
78# Tell Git to ignore README.google and BUILD.
79echo README.google >> .git/info/exclude
80echo BUILD >> .git/info/exclude
81g4 revert README.google
82g4 revert BUILD
83
benjaminwagnerf82c13f2015-08-18 06:25:14 -070084# Use google3 version of OWNERS.
benjaminwagner787ca872015-08-17 12:58:10 -070085find . \
benjaminwagnerf82c13f2015-08-18 06:25:14 -070086 -name OWNERS \
benjaminwagner787ca872015-08-17 12:58:10 -070087 -exec git update-index --skip-worktree \{\} \; \
88 -execdir g4 revert \{\} \;
89
benjaminwagnerf82c13f2015-08-18 06:25:14 -070090# Tell git to ignore these files that have Windows line endings, because Piper
91# will always change them to Unix line endings.
92git update-index --skip-worktree make.bat
93git update-index --skip-worktree make.py
94
benjaminwagner787ca872015-08-17 12:58:10 -070095# Tell git to ignore files left out of the rsync (i.e. "deleted" files).
96git status --porcelain | \
97 grep -e "^ D" | \
98 cut -c 4- | \
99 xargs git update-index --skip-worktree
100