fromupstream: wrap test description only if it is newly provided

Only wrap test description if it is newly provided via -t command line.
If the test description is from previous commit mesesage, for example
when using --replace, assume the test descriptions are already good.

BUG=none
TEST=fromupstream.py -b none -t "VERY_LONG_STRING..." \
     linux://238c30468f46b

Change-Id: I083826391da2a5e744cdb51482c65a666d24e616
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2345647
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Commit-Queue: Tzung-Bi Shih <tzungbi@chromium.org>
Tested-by: Tzung-Bi Shih <tzungbi@chromium.org>
diff --git a/contrib/fromupstream.py b/contrib/fromupstream.py
index ca35a6b..816f52b 100755
--- a/contrib/fromupstream.py
+++ b/contrib/fromupstream.py
@@ -167,7 +167,9 @@
 def _wrap_commit_line(prefix, content):
     line = prefix + '=' + content
     indent = ' ' * (len(prefix) + 1)
-    return textwrap.fill(line, COMMIT_MESSAGE_WIDTH, subsequent_indent=indent)
+
+    ret = textwrap.fill(line, COMMIT_MESSAGE_WIDTH, subsequent_indent=indent)
+    return ret[len(prefix) + 1:]
 
 def _pick_patchwork(url, patch_id, args):
     if args['tag'] is None:
@@ -452,6 +454,9 @@
     if buglist:
         args['bug'] = ', '.join(buglist)
 
+    if args['test']:
+        args['test'] = _wrap_commit_line('TEST', args['test'])
+
     if args['replace']:
         old_commit_message = _git(['show', '-s', '--format=%B', 'HEAD'])
 
@@ -526,7 +531,7 @@
         commit_message += '\n'
         commit_message += conflicts
         commit_message += '\n' + 'BUG=' + args['bug']
-        commit_message += '\n' + _wrap_commit_line('TEST', args['test'])
+        commit_message += '\n' + 'TEST=' + args['test']
 
         extra = []
         if args['signoff']: