fromupstream: Wrap long TEST= lines
Putting in a particularly long --test value would cause the upload hook
scripts to complain of a long line. This wraps TEST= lines to 75
characters, the length recommended by that lint error.
BUG=none
TEST=`fromupstream.py --test "$LONG_TEST_MESSAGE" ...` produces lines
wrapped to 75 characters.
Change-Id: I592c72de3439a25053b8fe00b1b954d2824f5281
Reviewed-on: https://chromium-review.googlesource.com/1469343
Commit-Ready: Harry Cutts <hcutts@chromium.org>
Tested-by: Harry Cutts <hcutts@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
diff --git a/contrib/fromupstream.py b/contrib/fromupstream.py
index 8fe3c6f..05d91df 100755
--- a/contrib/fromupstream.py
+++ b/contrib/fromupstream.py
@@ -16,6 +16,7 @@
import signal
import subprocess
import sys
+import textwrap
import urllib
LINUX_URLS = (
@@ -24,6 +25,8 @@
'https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git',
)
+COMMIT_MESSAGE_WIDTH = 75
+
_PWCLIENTRC = os.path.expanduser('~/.pwclientrc')
def _get_conflicts():
@@ -104,6 +107,11 @@
# Strip trailing 'xmlrpc' and/or trailing slash.
return re.sub('/(xmlrpc/)?$', '', url)
+def _wrap_commit_line(prefix, content):
+ line = prefix + '=' + content
+ indent = ' ' * (len(prefix) + 1)
+ return textwrap.fill(line, COMMIT_MESSAGE_WIDTH, subsequent_indent=indent)
+
def main(args):
"""This is the main entrypoint for fromupstream.
@@ -348,7 +356,7 @@
commit_message += '\n'
commit_message += conflicts
commit_message += '\n' + 'BUG=' + args['bug']
- commit_message += '\n' + 'TEST=' + args['test']
+ commit_message += '\n' + _wrap_commit_line('TEST', args['test'])
if args['signoff']:
extra = ['-s']
else: