From 7c61dcb36e8987e64cbdb39e28fc143fad002c09 Mon Sep 17 00:00:00 2001 From: Asanka Herath Date: Wed, 14 Dec 2016 13:01:58 -0500 Subject: [PATCH] [git-cl] Preserve line breaks when pretty printing CL description. Also set the line wrap limit to 72 + indent from 70 columns total. The latter was limiting the CL description to 68 columns total before wrapping kicked in. BUG=none Change-Id: I93c984c7b121d4bb042d0dc81a662352f77df4d1 Reviewed-on: https://chromium-review.googlesource.com/420243 Reviewed-by: Dirk Pranke Commit-Queue: Dirk Pranke --- git_cl.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git_cl.py b/git_cl.py index c7a1fc542..e089921fb 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1421,9 +1421,11 @@ class Changelist(object): self.description = self._codereview_impl.FetchDescription() self.has_description = True if pretty: - wrapper = textwrap.TextWrapper() + # Set width to 72 columns + 2 space indent. + wrapper = textwrap.TextWrapper(width=74, replace_whitespace=True) wrapper.initial_indent = wrapper.subsequent_indent = ' ' - return wrapper.fill(self.description) + lines = self.description.splitlines() + return '\n'.join([wrapper.fill(line) for line in lines]) return self.description def GetPatchset(self):