fromupstream: wrap long bug lines
Wraps long bug lines.
Separates --bug, --crbug, and --buganizer to different BUG= items.
1. long crbug lines
$ fromupstream.py --nosignoff -t none $(seq -f "--crbug %g" 1 20) \
-c XXX linux://238c30468f46b
$ git show -s
> [snip]
> BUG=chromium:1, chromium:2, chromium:3, chromium:4, chromium:5, chromium:6
> BUG=chromium:7, chromium:8, chromium:9, chromium:10, chromium:11
> BUG=chromium:12, chromium:13, chromium:14, chromium:15, chromium:16
> BUG=chromium:17, chromium:18, chromium:19, chromium:20
> TEST=none
>
> Change-Id: XXX
2. long buganizer lines
$ fromupstream.py --nosignoff -t none $(seq -f "--buganizer %g" 1 20) \
-c XXX linux://238c30468f46b
$ git show -s
> [snip]
> BUG=b:1, b:2, b:3, b:4, b:5, b:6, b:7, b:8, b:9, b:10, b:11, b:12, b:13
> BUG=b:14, b:15, b:16, b:17, b:18, b:19, b:20
> TEST=none
>
> Change-Id: XXX
3. long everything
$ fromupstream.py --nosignoff -t none -b b:1234 \
$(seq -f "--crbug %g" 1 20) $(seq -f "--buganizer %g" 1 20) \
-t "$(seq 1 100)" -c XXX linux://238c30468f46b
$ git show -s
> [snip]
> BUG=b:1234
> BUG=b:1, b:2, b:3, b:4, b:5, b:6, b:7, b:8, b:9, b:10, b:11, b:12, b:13
> BUG=b:14, b:15, b:16, b:17, b:18, b:19, b:20
> BUG=chromium:1, chromium:2, chromium:3, chromium:4, chromium:5, chromium:6
> BUG=chromium:7, chromium:8, chromium:9, chromium:10, chromium:11
> BUG=chromium:12, chromium:13, chromium:14, chromium:15, chromium:16
> BUG=chromium:17, chromium:18, chromium:19, chromium:20
> TEST=1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
> 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
> 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
> 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
> 96 97 98 99 100
>
> Change-Id: XXX
BUG=none
TEST=as shown above
Change-Id: Ifaa189582475cf18f3c7a37d4266cc156a7a755d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2359092
Tested-by: Tzung-Bi Shih <tzungbi@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Commit-Queue: Tzung-Bi Shih <tzungbi@chromium.org>
diff --git a/contrib/fromupstream.py b/contrib/fromupstream.py
index c2743f8..a353f0d 100755
--- a/contrib/fromupstream.py
+++ b/contrib/fromupstream.py
@@ -165,11 +165,11 @@
return re.sub('/(xmlrpc/)?$', '', url)
def _wrap_commit_line(prefix, content):
- line = prefix + '=' + content
- indent = ' ' * (len(prefix) + 1)
+ line = prefix + content
+ indent = ' ' * len(prefix)
ret = textwrap.fill(line, COMMIT_MESSAGE_WIDTH, subsequent_indent=indent)
- return ret[len(prefix) + 1:]
+ return ret[len(prefix):]
def _pick_patchwork(url, patch_id, args):
if args['tag'] is None:
@@ -450,14 +450,18 @@
cq_depends = [args['cqdepend']] if args['cqdepend'] else []
- buglist = [args['bug']] if args['bug'] else []
+ bug_lines = []
+ if args['bug']:
+ # un-wrap intentionally
+ bug_lines += [args['bug']]
if args['buganizer']:
- buglist += ['b:{0}'.format(x) for x in args['buganizer']]
+ buganizers = ', '.join('b:%d' % x for x in args['buganizer'])
+ bug_lines += [x.strip(' ,') for x in _wrap_commit_line('BUG=', buganizers).split('\n')]
if args['crbug']:
- buglist += ['chromium:{0}'.format(x) for x in args['crbug']]
- bug_lines = [', '.join(buglist)] if buglist else []
+ crbugs = ', '.join('chromium:%d' % x for x in args['crbug'])
+ bug_lines += [x.strip(' ,') for x in _wrap_commit_line('BUG=', crbugs).split('\n')]
- test_lines = [_wrap_commit_line('TEST', args['test'])] if args['test'] else []
+ test_lines = [_wrap_commit_line('TEST=', args['test'])] if args['test'] else []
if args['replace']:
old_commit_message = _git(['show', '-s', '--format=%B', 'HEAD'])