From d161d848cfef02e74baa91027a5dba559c2a0086 Mon Sep 17 00:00:00 2001 From: "mhm@chromium.org" Date: Sat, 12 Mar 2011 18:56:50 +0000 Subject: [PATCH] Reland - Support msysgit in gcl and git-cl An explicit msysgit check is needed since it requires the usage of 'env' to open the editor. BUG=70550, 70548 TEST=Win,Linux Review URL: http://codereview.chromium.org/6680019 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@77946 0039d316-1c4b-4281-b951-d872f2087c98 --- gcl.py | 17 ++++++++++++----- git_cl/git_cl.py | 9 +++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/gcl.py b/gcl.py index 6b198a23c..ce259bcfa 100755 --- a/gcl.py +++ b/gcl.py @@ -1063,11 +1063,18 @@ def CMDchange(args): os.write(handle, text) os.close(handle) - if not silent: - os.system(GetEditor() + " " + filename) - - result = gclient_utils.FileRead(filename, 'r') - os.remove(filename) + # Open up the default editor in the system to get the CL description. + cmd = [GetEditor(), filename] + if sys.platform == 'win32' and 'mingw\\bin' in os.environ['PATH']: + # Msysgit requires the usage of 'env' to be present. The only way to + # accomplish that is by reading the environment variable for mingw\bin. + cmd.insert(0, 'env') + try: + if not silent: + subprocess.check_call(cmd) + result = gclient_utils.FileRead(filename, 'r') + finally: + os.remove(filename) if not result: return 0 diff --git a/git_cl/git_cl.py b/git_cl/git_cl.py index 8677adb09..3b7ca3342 100644 --- a/git_cl/git_cl.py +++ b/git_cl/git_cl.py @@ -710,9 +710,14 @@ def UserEditedLog(starting_text): fileobj.write(starting_text) fileobj.close() - result = None + # Open up the default editor in the system to get the CL description. + cmd = [editor, filename] + if sys.platform == 'win32' and 'mingw\\bin' in os.environ['PATH']: + # Msysgit requires the usage of 'env' to be present. The only way to + # accomplish that is by reading the environment variable for mingw\bin. + cmd.insert(0, 'env') try: - subprocess.check_call(['env', editor, filename], shell=True) + subprocess.check_call(cmd) fileobj = open(filename) result = fileobj.read() fileobj.close()