From 3d4d7edc3da7895ebe7f2c7da5a1714c2da50c2b Mon Sep 17 00:00:00 2001 From: "mhm@chromium.org" Date: Sat, 12 Mar 2011 02:19:19 +0000 Subject: [PATCH] msysgit - Fix issue where git cl doesn't recognize editor. The unix editor doesn't popup resulting in a unsuccessful upload. This change successfully fixes it. BUG=70550 TEST=git cl upload works as expected under msysgit. Review URL: http://codereview.chromium.org/6679019 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@77910 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl/git_cl.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/git_cl/git_cl.py b/git_cl/git_cl.py index 5bbab8018..80329cbff 100644 --- a/git_cl/git_cl.py +++ b/git_cl/git_cl.py @@ -710,17 +710,20 @@ def UserEditedLog(starting_text): fileobj.write(starting_text) fileobj.close() - ret = subprocess.call(editor + ' ' + filename, shell=True) - if ret != 0: + result = None + try: + subprocess.check_call(['env', editor, filename], shell=True) + fileobj = open(filename) + result = fileobj.read() + fileobj.close() + finally: os.remove(filename) - return - fileobj = open(filename) - text = fileobj.read() - fileobj.close() - os.remove(filename) + if not result: + return + stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) - return stripcomment_re.sub('', text).strip() + return stripcomment_re.sub('', result).strip() def ConvertToInteger(inputval):