Patch #33118 ยป 0001-Detect-diff-files-in-e-mailed-issues-and-map-patch-t.patch
app/models/mail_handler.rb | ||
---|---|---|
504 | 504 | |
505 | 505 |
# If there is still no body found, and there are no mime-parts defined, |
506 | 506 |
# we use the whole raw mail body |
507 |
@plain_text_body ||= email_parts_to_text([email]).presence if email.all_parts.empty? |
|
507 |
if email.all_parts.empty? |
|
508 |
@plain_text_body ||= email_parts_to_text([email]).presence |
|
509 | ||
510 |
# map patch to attachment |
|
511 |
patch_to_attachement |
|
512 |
end |
|
508 | 513 | |
509 | 514 |
# As a fallback we return an empty plain text body (e.g. if we have only |
510 | 515 |
# empty text parts but a non-text attachment) |
... | ... | |
640 | 645 |
def find_assignee_from_keyword(keyword, issue) |
641 | 646 |
Principal.detect_by_keyword(issue.assignable_users, keyword) |
642 | 647 |
end |
648 | ||
649 |
# patch to attachement |
|
650 |
def patch_to_attachement |
|
651 |
return unless @plain_text_body =~ /^--- .*\n[+][+][+] .*\n@@/ |
|
652 |
return unless @plain_text_body =~ /^(---$|diff -|Index: )/ |
|
653 | ||
654 |
@plain_text_body = $` |
|
655 |
email.attachments['patch.diff'] = { |
|
656 |
:mime_type => 'text/x-diff', |
|
657 |
:content => email.to_s |
|
658 |
} |
|
659 |
end |
|
643 | 660 |
end |