blob: 7978f1986349fd24468e0e337d5a39b387d5c99d [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
benjaminwagner0ff46c02015-12-11 11:26:44 -08007# Syncs //depot/google3/third_party/skia/HEAD to the latest revision of Skia.
8# If this script is not run from a Piper client, creates a new CitC client. Also
9# updates README.google.
benjaminwagner787ca872015-08-17 12:58:10 -070010#
11# Usage:
12# ./tools/sync_google3.sh
13
benjaminwagner964eeba2015-10-20 13:00:48 -070014prodcertstatus -q || (echo "Please run prodaccess." 1>&2; exit 1)
15source gbash.sh || exit 2
benjaminwagner787ca872015-08-17 12:58:10 -070016
benjaminwagner964eeba2015-10-20 13:00:48 -070017set -e
benjaminwagner787ca872015-08-17 12:58:10 -070018
19MY_DIR="$(gbash::get_absolute_caller_dir)"
benjaminwagner0ff46c02015-12-11 11:26:44 -080020SKIA_REV="$(git ls-remote https://skia.googlesource.com/skia refs/heads/master | cut -f 1)"
benjaminwagner787ca872015-08-17 12:58:10 -070021
22gbash::get_google3_dir && GOOGLE3="$(gbash::get_google3_dir)"
23if [ -z "${GOOGLE3}" ]; then
24 CLIENT_NAME="sync_skia_$(date '+%F-%H-%M-%S')"
25 ${MY_DIR}/create_skia_google3_client.sh "${CLIENT_NAME}"
26 GOOGLE3="/google/src/cloud/${USER}/${CLIENT_NAME}/google3"
27fi
28cd "${GOOGLE3}/third_party/skia/HEAD"
benjaminwagner0ff46c02015-12-11 11:26:44 -080029${MY_DIR}/git_clone_to_google3.sh --skia_rev "${SKIA_REV}"
benjaminwagner787ca872015-08-17 12:58:10 -070030
benjaminwagner0ff46c02015-12-11 11:26:44 -080031echo "Synced client ${CLIENT_NAME} to ${SKIA_REV}"
benjaminwagner964eeba2015-10-20 13:00:48 -070032
benjaminwagner787ca872015-08-17 12:58:10 -070033# Update README.google.
benjaminwagner0ff46c02015-12-11 11:26:44 -080034sed --in-place "s/^Version: .*/Version: ${SKIA_REV}/" README.google
35sed --in-place "s/URL: http:\/\/skia.googlesource.com\/skia\/+archive\/.*\.tar\.gz/URL: http:\/\/skia.googlesource.com\/skia\/+archive\/${SKIA_REV}.tar.gz/" README.google
benjaminwagner787ca872015-08-17 12:58:10 -070036CURRENT_DATE=`date '+%d %B %Y'`
37echo "Updated using sync_google3.sh on $CURRENT_DATE by $USER@google.com" >> README.google
38
39# Add README.google to the default change.
40g4 reopen
41# Create a new CL.
benjaminwagner0ff46c02015-12-11 11:26:44 -080042CHANGE="$(g4 change --desc "Update skia HEAD to ${SKIA_REV}.")"
benjaminwagner787ca872015-08-17 12:58:10 -070043CL="$(echo "${CHANGE}" | sed "s/Change \([0-9]\+\) created.*/\1/")"
44
benjaminwagner964eeba2015-10-20 13:00:48 -070045echo "Created CL ${CL} (http://cl/${CL})"
46
47# Run presubmit (will run TAP tests).
48if g4 presubmit -c "${CL}"; then
49 echo "CL is ready for review and submit at http://cl/${CL}"
50else
51 echo "Presubmit failed for CL ${CL} in client ${CLIENT_NAME}" 1>&2
52 exit 3
53fi