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
diff --git a/git_cl/git_cl.py b/git_cl/git_cl.py
index 5bbab80..80329cb 100644
--- a/git_cl/git_cl.py
+++ b/git_cl/git_cl.py
@@ -710,17 +710,20 @@
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):