2015-08-17 19:58:10 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright 2014 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2015-12-11 19:26:44 +00:00
|
|
|
# Syncs //depot/google3/third_party/skia/HEAD to the latest revision of Skia.
|
|
|
|
# If this script is not run from a Piper client, creates a new CitC client. Also
|
|
|
|
# updates README.google.
|
2015-08-17 19:58:10 +00:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# ./tools/sync_google3.sh
|
|
|
|
|
2015-10-20 20:00:48 +00:00
|
|
|
prodcertstatus -q || (echo "Please run prodaccess." 1>&2; exit 1)
|
|
|
|
source gbash.sh || exit 2
|
2015-08-17 19:58:10 +00:00
|
|
|
|
2015-10-20 20:00:48 +00:00
|
|
|
set -e
|
2015-08-17 19:58:10 +00:00
|
|
|
|
|
|
|
MY_DIR="$(gbash::get_absolute_caller_dir)"
|
2015-12-11 19:26:44 +00:00
|
|
|
SKIA_REV="$(git ls-remote https://skia.googlesource.com/skia refs/heads/master | cut -f 1)"
|
2015-08-17 19:58:10 +00:00
|
|
|
|
|
|
|
gbash::get_google3_dir && GOOGLE3="$(gbash::get_google3_dir)"
|
|
|
|
if [ -z "${GOOGLE3}" ]; then
|
|
|
|
CLIENT_NAME="sync_skia_$(date '+%F-%H-%M-%S')"
|
|
|
|
${MY_DIR}/create_skia_google3_client.sh "${CLIENT_NAME}"
|
|
|
|
GOOGLE3="/google/src/cloud/${USER}/${CLIENT_NAME}/google3"
|
|
|
|
fi
|
|
|
|
cd "${GOOGLE3}/third_party/skia/HEAD"
|
2015-12-11 19:26:44 +00:00
|
|
|
${MY_DIR}/git_clone_to_google3.sh --skia_rev "${SKIA_REV}"
|
2015-08-17 19:58:10 +00:00
|
|
|
|
2015-12-11 19:26:44 +00:00
|
|
|
echo "Synced client ${CLIENT_NAME} to ${SKIA_REV}"
|
2015-10-20 20:00:48 +00:00
|
|
|
|
2015-12-14 20:41:10 +00:00
|
|
|
# Grab previous Git revision.
|
|
|
|
GOOGLE3_REV="$(grep "Version: " README.google | cut -d ' ' -f 2)"
|
|
|
|
|
2015-08-17 19:58:10 +00:00
|
|
|
# Update README.google.
|
2015-12-11 19:26:44 +00:00
|
|
|
sed --in-place "s/^Version: .*/Version: ${SKIA_REV}/" README.google
|
2015-12-14 20:41:10 +00:00
|
|
|
sed --in-place "s/URL: https:\/\/skia.googlesource.com\/skia\/+archive\/.*\.tar\.gz/URL: https:\/\/skia.googlesource.com\/skia\/+archive\/${SKIA_REV}.tar.gz/" README.google
|
2015-08-17 19:58:10 +00:00
|
|
|
|
|
|
|
# Add README.google to the default change.
|
|
|
|
g4 reopen
|
2015-12-14 20:41:10 +00:00
|
|
|
|
|
|
|
# Generate commit description.
|
|
|
|
CURRENT_DATE=`date '+%d %B %Y'`
|
|
|
|
COMMIT_RANGE="${GOOGLE3_REV:0:9}..${SKIA_REV:0:9}"
|
|
|
|
CHANGES="$(git log ${COMMIT_RANGE} --date=short --no-merges --format='%ad %ae %s')"
|
|
|
|
COMMITS="$(wc -l <<EOF
|
|
|
|
${CHANGES}
|
|
|
|
EOF
|
|
|
|
)"
|
|
|
|
DESC="$(cat <<EOF
|
|
|
|
Roll Skia ${COMMIT_RANGE} (${COMMITS} commits)
|
|
|
|
|
|
|
|
https://chromium.googlesource.com/skia.git/+log/${COMMIT_RANGE}
|
|
|
|
|
|
|
|
$ git log ${COMMIT_RANGE} --date=short --no-merges --format='%ad %ae %s'
|
|
|
|
${CHANGES}
|
|
|
|
|
|
|
|
Change created by sync_google3.sh on ${CURRENT_DATE} by ${USER}
|
|
|
|
EOF
|
|
|
|
)"
|
|
|
|
|
2015-08-17 19:58:10 +00:00
|
|
|
# Create a new CL.
|
2015-12-14 20:41:10 +00:00
|
|
|
CHANGE="$(g4 change --desc "${DESC}.")"
|
2015-08-17 19:58:10 +00:00
|
|
|
CL="$(echo "${CHANGE}" | sed "s/Change \([0-9]\+\) created.*/\1/")"
|
|
|
|
|
2015-10-20 20:00:48 +00:00
|
|
|
echo "Created CL ${CL} (http://cl/${CL})"
|
|
|
|
|
|
|
|
# Run presubmit (will run TAP tests).
|
|
|
|
if g4 presubmit -c "${CL}"; then
|
|
|
|
echo "CL is ready for review and submit at http://cl/${CL}"
|
|
|
|
else
|
|
|
|
echo "Presubmit failed for CL ${CL} in client ${CLIENT_NAME}" 1>&2
|
|
|
|
exit 3
|
|
|
|
fi
|