[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 <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index c7a1fc5..e089921 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1421,9 +1421,11 @@
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):