|
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'): |
@@ -525,9 +522,38 @@ def modify(settings): |
525 | 522 | params['status'] = 'RESOLVED' |
526 | 523 | params['resolution'] = 'INVALID' |
527 | 524 |
|
| 525 | + check_auth(settings) |
| 526 | + |
| 527 | + if hasattr(settings, 'comment_editor'): |
| 528 | + quotes='' |
| 529 | + if hasattr(settings, 'quote'): |
| 530 | + bug_comments = settings.call_bz(settings.bz.Bug.comments, params) |
| 531 | + bug_comments = bug_comments['bugs']['%s' % settings.bugid]\ |
| 532 | + ['comments'][-settings.quote:] |
| 533 | + wrapper = textwrap.TextWrapper(width=settings.columns, |
| 534 | + break_long_words=False, |
| 535 | + break_on_hyphens=False) |
| 536 | + for comment in bug_comments: |
| 537 | + what = comment['text'] |
| 538 | + if what is None: |
| 539 | + continue |
| 540 | + who = comment['creator'] |
| 541 | + when = comment['time'] |
| 542 | + when = datetime.datetime.strptime(str(when), '%Y%m%dT%H:%M:%S') |
| 543 | + quotes += 'On %s, %s wrote:\n' % \ |
| 544 | + (when.strftime('%Y-%m-%d %H:%M:%S UTC'), who) |
| 545 | + for line in what.splitlines(): |
| 546 | + if len(line) < settings.columns: |
| 547 | + quotes += '> %s\n' % line |
| 548 | + else: |
| 549 | + for shortline in wrapper.wrap(line): |
| 550 | + quotes += '> %s\n' % shortline |
| 551 | + settings.comment = block_edit('Enter comment:', |
| 552 | + comment_from=settings.comment, |
| 553 | + quotes=quotes) |
| 554 | + |
528 | 555 | if len(params) < 2: |
529 | 556 | raise BugzError('No changes were specified') |
530 | | - check_auth(settings) |
531 | 557 | result = settings.call_bz(settings.bz.Bug.update, params) |
532 | 558 | for bug in result['bugs']: |
533 | 559 | changes = bug['changes'] |
|
0 commit comments