Add script to create a local Chromium git repository.
BUG=none TEST=creates a working Chromium git repository in src Review URL: http://codereview.chromium.org/173599 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@24991 0039d316-1c4b-4281-b951-d872f2087c98experimental/szager/collated-output
parent
4e63365629
commit
5ef7f34448
@ -0,0 +1,194 @@
|
||||
#!/bin/bash -e
|
||||
#
|
||||
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
#
|
||||
# create-chromium-git-src
|
||||
#
|
||||
# Create and configure a local Chromium git repository.
|
||||
#
|
||||
|
||||
GITSERVER="${GITSERVER:-git.chromium.org}"
|
||||
TMP=".create_chromium_git_src.$$"
|
||||
|
||||
function cleanup {
|
||||
rm -rf "${TMP}"
|
||||
}
|
||||
|
||||
trap 'cleanup; echo Failure!; tput bel; exit 1' TERM QUIT HUP INT EXIT
|
||||
|
||||
function get_email {
|
||||
# Get user email address.
|
||||
EMAIL=""
|
||||
while [ "x${EMAIL}" = "x" ]; do
|
||||
echo -n "Email address git should configure in your checkout: "
|
||||
read EMAIL
|
||||
if [ "x${EMAIL}" = "x${EMAIL%@*}" ]; then
|
||||
echo "Invalid email address (must contain @)!"
|
||||
EMAIL=""
|
||||
fi
|
||||
done
|
||||
echo -n "Using ${EMAIL} for email address... "
|
||||
sleep 1
|
||||
echo OK
|
||||
}
|
||||
|
||||
# Verify we can write to particular directories.
|
||||
function check_dirs {
|
||||
if [ -d src ]; then
|
||||
echo "Found a src directory, do you already have a Chromium checkout?"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Test git and git --version.
|
||||
function test_git {
|
||||
echo -n "Trying git... "
|
||||
local GITV="$(git --version 2>&1)" || {
|
||||
echo "git isn't installed, please install it"
|
||||
exit 1
|
||||
}
|
||||
|
||||
GITV="${GITV##* }" # Only examine last word (i.e. version number)
|
||||
local GITD=( ${GITV//./ } ) # Split version number into decimals
|
||||
if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then
|
||||
echo FAIL
|
||||
echo "git version is ${GITV}, please update to a version later than 1.6"
|
||||
exit 1
|
||||
fi
|
||||
echo OK
|
||||
}
|
||||
|
||||
# Test git svn and git svn --version.
|
||||
function test_git_svn {
|
||||
echo -n "Trying git-svn... "
|
||||
rm -rf "${TMP}"
|
||||
git clone git://github.com/git/hello-world.git "${TMP}" &>/dev/null &&
|
||||
local GITV="$(cd "${TMP}" && git svn --version 2>/dev/null)" || {
|
||||
echo FAIL
|
||||
echo "git-svn isn't installed, please install it"
|
||||
exit 1
|
||||
}
|
||||
|
||||
GITV="${GITV#* version }" # git svn --version has extra output to remove.
|
||||
GITV="${GITV% (svn*}"
|
||||
local GITD=( ${GITV//./ } ) # Split version number into decimals
|
||||
if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then
|
||||
echo FAIL
|
||||
echo "git version is ${GITV}, please update to a version later than 1.6"
|
||||
exit 1
|
||||
fi
|
||||
echo OK
|
||||
}
|
||||
|
||||
# Verify we can reach our main git URL.
|
||||
function test_git_url {
|
||||
echo -n "Testing Chromium git URL... "
|
||||
mkdir -p "${TMP}"
|
||||
(cd "${TMP}" &&
|
||||
rm -rf .git .gitignore &&
|
||||
git init &&
|
||||
git remote add origin git://"${GITSERVER}"/chromium.git &&
|
||||
git remote show origin) &>/dev/null &
|
||||
local pid=$!
|
||||
{ sleep 10 && kill "${pid}"; } &>/dev/null &
|
||||
wait "${pid}" &>/dev/null || {
|
||||
echo FAIL
|
||||
echo "Timeout accessing Chromium git URL, is ${GITSERVER} correct?"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
}
|
||||
|
||||
# Grab a clone of the Chromium git repository.
|
||||
function grab_crgit {
|
||||
echo "Grabbing Chromium git repository..."
|
||||
git clone git://"${GITSERVER}"/chromium.git src || {
|
||||
echo "git clone exited with error"
|
||||
echo "You should probably remove 'src' before retrying"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Configure the git repository to know about the upstream SVN server.
|
||||
function git_svn_init {
|
||||
echo -n "Configuring upstream SVN... "
|
||||
(cd src && git svn init --prefix=origin/ -T trunk/src \
|
||||
svn://svn.chromium.org/chrome) &>/dev/null || {
|
||||
echo FAIL
|
||||
echo "'git svn init' exited with error"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
}
|
||||
|
||||
# Initialize the SVN history in the repository, also sanity checks our upstream
|
||||
# SVN configuration.
|
||||
function git_svn_fetch {
|
||||
echo "Fetching SVN history..."
|
||||
(cd src && git svn fetch && git pull) || {
|
||||
echo "'git svn fetch' exited with error"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Remaining configuration of the git repository:
|
||||
# - associate with codereview/rietveld
|
||||
# - set the repository's email address
|
||||
# - disable crlf munging
|
||||
# - grab a stock .gclient file
|
||||
function git_config {
|
||||
echo -n "Associating with Rietveld... "
|
||||
(cd src && git cl config http://src.chromium.org/svn/)
|
||||
echo OK
|
||||
|
||||
echo -n "Configuring email address (git config user.email ${EMAIL})... "
|
||||
(cd src && git config user.email "${EMAIL}")
|
||||
echo OK
|
||||
|
||||
echo -n "Disabling crlf munging... "
|
||||
(cd src && git config --global core.autocrlf false)
|
||||
echo OK
|
||||
|
||||
echo -n "Creating a .gclient file... "
|
||||
gclient config http://src.chromium.org/svn/trunk/src
|
||||
echo OK
|
||||
}
|
||||
|
||||
get_email
|
||||
check_dirs
|
||||
test_git
|
||||
test_git_svn
|
||||
test_git_url
|
||||
grab_crgit
|
||||
git_svn_init
|
||||
git_svn_fetch
|
||||
git_config
|
||||
|
||||
echo
|
||||
echo "A Chromium Git repository was created in 'src'."
|
||||
echo
|
||||
echo " To create a CL..."
|
||||
echo " Update: git pull && gclient sync"
|
||||
echo " Create and use a branch mychange: git checkout -q -b mychange origin"
|
||||
echo " Edit files and commit: git commit -a -v"
|
||||
echo " Upload CL: git cl upload"
|
||||
echo " Try a change: git try origin"
|
||||
echo " Commit a CL: git cl dcommit"
|
||||
echo " Switch to the trunk: git checkout trunk"
|
||||
echo " Delete a branch mychange: git branch -d mychange"
|
||||
echo
|
||||
echo " If while on a branch you need to switch back to the trunk..."
|
||||
echo " Switch to the trunk: git checkout trunk"
|
||||
echo " List all branches: git branch"
|
||||
echo " Switch to branch mychange: git checkout mychange"
|
||||
echo
|
||||
echo " Examining files and changes..."
|
||||
echo " Log with patches: git log -p"
|
||||
echo " Changes to DEPS: git log -p DEPS"
|
||||
echo " View latest commit: git cat-file commit HEAD"
|
||||
echo
|
||||
echo "You should run: gclient sync"
|
||||
echo
|
||||
trap cleanup EXIT
|
||||
Loading…
Reference in New Issue