Commit 4c6e404c authored by cmp@chromium.org's avatar cmp@chromium.org

Make git-cl and update_depot_tools msys-compatible.

This change makes it possible to run 'git cl' from
a Command Prompt using only the auto-installed git
from depot_tools.  It is needed because in MSysGit,
'git cl' invokes 'git' which calls 'git-cl'.  While
'git-cl' is pulled from depot_tools (since it's in
PATH), depot_tools/python_bin is not in PATH, and
so we execute git_cl.py through our auto-installed
python.exe directly.

update_depot_tools is fixed so that if we find
the auto-installed svn and git in depot_tools, we
execute those directly, otherwise falling back to
calling them based on PATH.

In both git-cl and update_depot_tools, we only enable
this new behavior if uname in PATH reports a 'MINGW'
environment.  This should not trigger on any other
environment where uname exists, including Cygwin which
should report 'CYGWIN'.
Review URL: http://codereview.chromium.org/7020035

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@87510 0039d316-1c4b-4281-b951-d872f2087c98
parent 12649efc
#!/bin/sh
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Copyright (c) 2011 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.
......@@ -9,4 +9,14 @@
base_dir=$(dirname "$0")
"$base_dir"/update_depot_tools
"$base_dir"/git_cl.py "$@"
# Test if this script is running under a MSys install. If it is, we will
# hardcode the path to Python where possible.
OUTPUT="$(uname | grep 'MINGW')"
MINGW=$?
if [ -d "$base_dir/python_bin" -a $MINGW = 0 ]; then
exec "$base_dir/python_bin/python.exe" "$base_dir"/git_cl.py "$@"
else
exec "$base_dir/git_cl.py" "$@"
fi
#!/usr/bin/env bash
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Copyright (c) 2011 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.
......@@ -17,9 +17,24 @@ then
base_dir=`cd "$base_dir" && pwd -P`
fi
# Test if this script is running under a MSys install. If it is, we will
# hardcode the paths to SVN and Git where possible.
OUTPUT="$(uname | grep 'MINGW')"
MINGW=$?
SVN="svn"
if [ -d "$base_dir/svn_bin" -a $MINGW = 0 ]; then
SVN="$base_dir/svn_bin/svn.exe"
fi
GIT="git"
if [ -d "$base_dir/git_bin" -a $MINGW = 0 ]; then
GIT="$base_dir/git_bin/bin/git.exe"
fi
# Test git and git --version.
function test_git {
local GITV="$(git --version)" || {
local GITV="$("$GIT" --version)" || {
echo "git isn't installed, please install it"
exit 1
}
......@@ -34,7 +49,7 @@ function test_git {
# Test git svn and git svn --version.
function test_git_svn {
local GITV="$(git svn --version)" || {
local GITV="$("$GIT" svn --version)" || {
echo "git-svn isn't installed, please install it"
exit 1
}
......@@ -50,7 +65,7 @@ function test_git_svn {
# Get the current SVN revision.
get_svn_revision() {
LANGUAGE=C svn info "$base_dir" | \
LANGUAGE=C "$SVN" info "$base_dir" | \
awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}'
}
......@@ -60,7 +75,7 @@ then
cd $base_dir
test_git_svn
# work around a git-svn --quiet bug
OUTPUT=`git svn rebase -q -q`
OUTPUT=`"$GIT" svn rebase -q -q`
if [[ ! "$OUTPUT" == *Current.branch* ]]; then
echo $OUTPUT 1>&2
fi
......@@ -73,7 +88,7 @@ then
# Update the bootstrap directory to stay up-to-date with the latest
# depot_tools.
BEFORE_REVISION=$(get_svn_revision)
svn -q up "$base_dir"
"$SVN" -q up "$base_dir"
AFTER_REVISION=$(get_svn_revision)
if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then
echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment