Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: gclient_utils.py

Issue 1905693002: Ensure files passed to the editor by RunEditor end in a new line (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index 21c44c36a786bc5f9e6b84a3ccef0b9b2f5cc84a..9d1b9dfdd19b981172f19df83e360d12d935dfe6 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -1084,7 +1084,11 @@ def RunEditor(content, git, git_editor=None):
'!! Please remove \\r from your change description !!')
fileobj = os.fdopen(file_handle, 'w')
# Still remove \r if present.
- fileobj.write(re.sub('\r?\n', '\n', content))
+ content = re.sub('\r?\n', '\n', content)
+ # Some editors complain when the file doesn't end in \n.
+ if not content.endswith('\n'):
+ content += '\n'
+ fileobj.write(content)
fileobj.close()
try:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698