diff --git a/git-try b/git-try index be8083af2..fc6b3629f 100755 --- a/git-try +++ b/git-try @@ -1,65 +1,17 @@ -#!/usr/bin/python -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +#!/bin/sh +# 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. -"""Wrapper for trychange.py for git checkout.""" -import logging -import sys +base_dir=$(dirname "$0") -import breakpad # pylint: disable=W0611 +# 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=$? -import gclient_utils -from scm import GIT -import third_party.upload -import trychange - - -def GetRietveldIssueNumber(): - try: - return GIT.Capture( - ['config', 'branch.%s.rietveldissue' % GIT.GetBranch(None)]) - except gclient_utils.Error: - return None - - -def GetRietveldPatchsetNumber(): - try: - return GIT.Capture( - ['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch(None)]) - except gclient_utils.Error: - return None - - -def GetRietveldServerUrl(): - try: - return GIT.Capture(['config', 'rietveld.server']).strip() - except gclient_utils.Error: - return None - - -if __name__ == '__main__': - args = sys.argv[1:] - patchset = GetRietveldPatchsetNumber() - if patchset: - args.extend([ - '--issue', GetRietveldIssueNumber(), - '--patchset', patchset, - ]) - else: - rietveld_url = GetRietveldServerUrl() - if rietveld_url: - args.extend(['--rietveld_url', GetRietveldServerUrl()]) - # Hack around a limitation in logging. - logging.getLogger().handlers = [] - try: - sys.exit(trychange.TryChange( - args, file_list=[], swallow_exception=False, - prog='git-try', - extra_epilog='\n' - 'git-try will diff against your tracked branch and will ' - 'detect your rietveld\n' - 'code review if you are using git-cl\n')) - except third_party.upload.ClientLoginError, e: - print('Got an exception while trying to log in to Rietveld.') - print(str(e)) +if [ -d "$base_dir/python_bin" -a $MINGW = 0 ]; then + exec "$base_dir/python_bin/python.exe" "$base_dir"/git_try.py "$@" +else + exec "$base_dir/git_try.py" "$@" +fi diff --git a/git_try.py b/git_try.py new file mode 100755 index 000000000..d5b98d838 --- /dev/null +++ b/git_try.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# 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. +"""Wrapper for trychange.py for git checkout.""" + +import logging +import sys + +import breakpad # pylint: disable=W0611 + +import gclient_utils +from scm import GIT +import third_party.upload +import trychange + + +def GetRietveldIssueNumber(): + try: + return GIT.Capture( + ['config', 'branch.%s.rietveldissue' % GIT.GetBranch(None)]) + except gclient_utils.Error: + return None + + +def GetRietveldPatchsetNumber(): + try: + return GIT.Capture( + ['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch(None)]) + except gclient_utils.Error: + return None + + +def GetRietveldServerUrl(): + try: + return GIT.Capture(['config', 'rietveld.server']).strip() + except gclient_utils.Error: + return None + + +if __name__ == '__main__': + args = sys.argv[1:] + patchset = GetRietveldPatchsetNumber() + if patchset: + args.extend([ + '--issue', GetRietveldIssueNumber(), + '--patchset', patchset, + ]) + else: + rietveld_url = GetRietveldServerUrl() + if rietveld_url: + args.extend(['--rietveld_url', GetRietveldServerUrl()]) + # Hack around a limitation in logging. + logging.getLogger().handlers = [] + try: + sys.exit(trychange.TryChange( + args, file_list=[], swallow_exception=False, + prog='git-try', + extra_epilog='\n' + 'git try will diff against your tracked branch and will ' + 'detect your rietveld\n' + 'code review if you are using git-cl\n')) + except third_party.upload.ClientLoginError, e: + print('Got an exception while trying to log in to Rietveld.') + print(str(e))