|
17 | 17 |
|
18 | 18 | """ |
19 | 19 |
|
| 20 | +import datetime |
20 | 21 | import getpass |
21 | 22 | import os |
22 | 23 | import re |
@@ -422,10 +423,6 @@ def modify(settings): |
422 | 423 | hasattr(settings, 'reset_assigned_to'): |
423 | 424 | raise BugzError('--assigned-to and --unassign cannot be used together') |
424 | 425 |
|
425 | | - if hasattr(settings, 'comment_editor'): |
426 | | - settings.comment = block_edit('Enter comment:', |
427 | | - comment_from=settings.comment) |
428 | | - |
429 | 426 | params = {} |
430 | 427 | params['ids'] = [settings.bugid] |
431 | 428 | if hasattr(settings, 'alias'): |
@@ -456,10 +453,6 @@ def modify(settings): |
456 | 453 | if 'cc' not in params: |
457 | 454 | params['cc'] = {} |
458 | 455 | params['cc']['remove'] = settings.cc_remove |
459 | | - if hasattr(settings, 'comment'): |
460 | | - if 'comment' not in params: |
461 | | - params['comment'] = {} |
462 | | - params['comment']['body'] = settings.comment |
463 | 456 | if hasattr(settings, 'component'): |
464 | 457 | params['component'] = settings.component |
465 | 458 | if hasattr(settings, 'dupe_of'): |
@@ -525,9 +518,43 @@ def modify(settings): |
525 | 518 | params['status'] = 'RESOLVED' |
526 | 519 | params['resolution'] = 'INVALID' |
527 | 520 |
|
| 521 | + check_auth(settings) |
| 522 | + |
| 523 | + if hasattr(settings, 'comment_editor'): |
| 524 | + quotes='' |
| 525 | + if hasattr(settings, 'quote'): |
| 526 | + bug_comments = settings.call_bz(settings.bz.Bug.comments, params) |
| 527 | + bug_comments = bug_comments['bugs']['%s' % settings.bugid]\ |
| 528 | + ['comments'][-settings.quote:] |
| 529 | + wrapper = textwrap.TextWrapper(width=settings.columns, |
| 530 | + break_long_words=False, |
| 531 | + break_on_hyphens=False) |
| 532 | + for comment in bug_comments: |
| 533 | + what = comment['text'] |
| 534 | + if what is None: |
| 535 | + continue |
| 536 | + who = comment['creator'] |
| 537 | + when = comment['time'] |
| 538 | + when = datetime.datetime.strptime(str(when), '%Y%m%dT%H:%M:%S') |
| 539 | + quotes += 'On %s, %s wrote:\n' % \ |
| 540 | + (when.strftime('%Y-%m-%d %H:%M:%S UTC'), who) |
| 541 | + for line in what.splitlines(): |
| 542 | + if len(line) < settings.columns: |
| 543 | + quotes += '> %s\n' % line |
| 544 | + else: |
| 545 | + for shortline in wrapper.wrap(line): |
| 546 | + quotes += '> %s\n' % shortline |
| 547 | + settings.comment = block_edit('Enter comment:', |
| 548 | + comment_from=settings.comment, |
| 549 | + quotes=quotes) |
| 550 | + |
| 551 | + if hasattr(settings, 'comment'): |
| 552 | + if 'comment' not in params: |
| 553 | + params['comment'] = {} |
| 554 | + params['comment']['body'] = settings.comment |
| 555 | + |
528 | 556 | if len(params) < 2: |
529 | 557 | raise BugzError('No changes were specified') |
530 | | - check_auth(settings) |
531 | 558 | result = settings.call_bz(settings.bz.Bug.update, params) |
532 | 559 | for bug in result['bugs']: |
533 | 560 | changes = bug['changes'] |
|
0 commit comments