Commit 38112359 authored by mmoss@chromium.org's avatar mmoss@chromium.org

Generalize python_git_runner for use in non-git scripts.

Also fixes an msys (git-bash) incompatibility, similar to the one
fixed in crrev.com/4845f0ed.

This change doesn't actually use the wrapper in any new places, but
subsequent changes will be made to use it in places where
'exec python' is called directly, like gclient and fetch.

BUG=411518
R=iannucci@google.com

Review URL: https://codereview.chromium.org/1415993003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297357 0039d316-1c4b-4281-b951-d872f2087c98
parent f2214673
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -5,4 +5,4 @@ ...@@ -5,4 +5,4 @@
SCRIPT=git_freezer.py SCRIPT=git_freezer.py
set -- freeze "$@" set -- freeze "$@"
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) | less -R . $(type -P python_runner.sh) | less -R
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -5,4 +5,4 @@ ...@@ -5,4 +5,4 @@
SCRIPT=git_retry.py SCRIPT=git_retry.py
set -- retry "$@" set -- retry "$@"
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -10,4 +10,4 @@ ...@@ -10,4 +10,4 @@
SCRIPT=git_freezer.py SCRIPT=git_freezer.py
set -- thaw "$@" set -- thaw "$@"
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
# git_try.py - Commits a patch to the SVN try patch repo. # git_try.py - Commits a patch to the SVN try patch repo.
# It is highly recommended to use `git cl try` instead. # It is highly recommended to use `git cl try` instead.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
# git_upstream_diff.py -- Provide the diff between the current branch and its # git_upstream_diff.py -- Provide the diff between the current branch and its
# upstream. # upstream.
. $(type -P python_git_runner.sh) . $(type -P python_runner.sh)
# Copyright 2014 The Chromium Authors. All rights reserved. # Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
## This file is designed to be sourced from a bash script whose name takes the ## This file is designed to be sourced from a bash script whose name takes the
## form 'git-sub-command'. This script will then instead invoke ## form 'command-name'. This script will then instead invoke
## '[depot_tools]/git_sub_command.py' correctly under mingw as well ## '[depot_tools]/command_name.py' correctly under mingw as well
## as posix-ey systems, passing along all other command line flags. ## as posix-ey systems, passing along all other command line flags.
## Example: ## Example:
## echo ". python_git_runner.sh" > git-foo-command ## echo ". python_runner.sh" > git-foo-command
## ./git-foo-command #=> runs `python git_foo_command.py` ## ./git-foo-command #=> runs `python git_foo_command.py`
## Constants ## Constants
...@@ -19,14 +19,14 @@ PYTHONDONTWRITEBYTECODE=1 ...@@ -19,14 +19,14 @@ PYTHONDONTWRITEBYTECODE=1
# #
# SCRIPT defaults to the basename of $0, with dashes replaced with underscores # SCRIPT defaults to the basename of $0, with dashes replaced with underscores
if [[ $OSTYPE = msys ]] DEPOT_TOOLS="${0%/*}"
then # Sometimes commands will run with no path (e.g. a git command run from within
DEPOT_TOOLS="${0%\\*}" # the depot_tools dir itself). In that case, treat it like it was run like:
BASENAME="${0##*\\}" # "./command"
else if [[ "$DEPOT_TOOLS" = "$0" ]]; then
DEPOT_TOOLS="${0%/*}" DEPOT_TOOLS="."
BASENAME="${0##*/}"
fi fi
BASENAME="${0##*/}"
SCRIPT="${SCRIPT-${BASENAME//-/_}.py}" SCRIPT="${SCRIPT-${BASENAME//-/_}.py}"
if [[ -e "$DEPOT_TOOLS/python.bat" && $OSTYPE = msys ]]; then if [[ -e "$DEPOT_TOOLS/python.bat" && $OSTYPE = msys ]]; then
......
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