|
42 | 42 | from django.utils.six.moves import map
|
43 | 43 |
|
44 | 44 | from patchwork.models import (Patch, Project, Person, Comment, State,
|
45 |
| - DelegationRule, get_default_initial_patch_state) |
| 45 | + DelegationRule, Submission, CoverLetter, |
| 46 | + get_default_initial_patch_state) |
46 | 47 | from patchwork.parser import parse_patch, patch_get_filenames
|
47 | 48 |
|
48 | 49 | LOGGER = logging.getLogger(__name__)
|
@@ -280,15 +281,13 @@ def find_content(project, mail):
|
280 | 281 | return patchbuf, commentbuf
|
281 | 282 |
|
282 | 283 |
|
283 |
| -def find_patch_for_comment(project, refs): |
| 284 | +def find_submission_for_comment(project, refs): |
284 | 285 | for ref in refs:
|
285 |
| - patch = None |
286 |
| - |
287 | 286 | # first, check for a direct reply
|
288 | 287 | try:
|
289 |
| - patch = Patch.objects.get(project=project, msgid=ref) |
290 |
| - return patch |
291 |
| - except Patch.DoesNotExist: |
| 288 | + submission = Submission.objects.get(project=project, msgid=ref) |
| 289 | + return submission |
| 290 | + except Submission.DoesNotExist: |
292 | 291 | pass
|
293 | 292 |
|
294 | 293 | # see if we have comments that refer to a patch
|
@@ -462,7 +461,8 @@ def parse_mail(mail, list_id=None):
|
462 | 461 |
|
463 | 462 | msgid = mail.get('Message-Id').strip()
|
464 | 463 | author, save_required = find_author(mail)
|
465 |
| - name, _ = clean_subject(mail.get('Subject'), [project.linkname]) |
| 464 | + name, prefixes = clean_subject(mail.get('Subject'), [project.linkname]) |
| 465 | + x, n = parse_series_marker(prefixes) |
466 | 466 | refs = find_references(mail)
|
467 | 467 | date = find_date(mail)
|
468 | 468 | headers = find_headers(mail)
|
@@ -496,12 +496,28 @@ def parse_mail(mail, list_id=None):
|
496 | 496 | LOGGER.debug('Patch saved')
|
497 | 497 |
|
498 | 498 | return patch
|
| 499 | + elif refs == [] and x == 0: # cover letters |
| 500 | + if save_required: |
| 501 | + author.save() |
| 502 | + |
| 503 | + cover_letter = CoverLetter( |
| 504 | + msgid=msgid, |
| 505 | + project=project, |
| 506 | + name=name, |
| 507 | + date=date, |
| 508 | + headers=headers, |
| 509 | + submitter=author, |
| 510 | + content=message) |
| 511 | + cover_letter.save() |
| 512 | + LOGGER.debug('Cover letter saved') |
| 513 | + |
| 514 | + return cover_letter |
499 | 515 |
|
500 | 516 | # comments
|
501 | 517 |
|
502 | 518 | # we only save comments if we have the parent email
|
503 |
| - patch = find_patch_for_comment(project, refs) |
504 |
| - if not patch: |
| 519 | + submission = find_submission_for_comment(project, refs) |
| 520 | + if not submission: |
505 | 521 | return
|
506 | 522 |
|
507 | 523 | # ...and we only save the author if we're saving the comment
|
|
0 commit comments