Patch #33118 ยป 0001-Detect-diff-files-in-e-mailed-issues-and-map-patch-t.patch
| app/models/mail_handler.rb | ||
|---|---|---|
|
# If there is still no body found, and there are no mime-parts defined,
|
||
|
# we use the whole raw mail body
|
||
|
@plain_text_body ||= email_parts_to_text([email]).presence if email.all_parts.empty?
|
||
|
if email.all_parts.empty?
|
||
|
@plain_text_body ||= email_parts_to_text([email]).presence
|
||
|
# map patch to attachment
|
||
|
patch_to_attachement
|
||
|
end
|
||
|
# As a fallback we return an empty plain text body (e.g. if we have only
|
||
|
# empty text parts but a non-text attachment)
|
||
| ... | ... | |
|
def find_assignee_from_keyword(keyword, issue)
|
||
|
Principal.detect_by_keyword(issue.assignable_users, keyword)
|
||
|
end
|
||
|
# patch to attachement
|
||
|
def patch_to_attachement
|
||
|
return unless @plain_text_body =~ /^--- .*\n[+][+][+] .*\n@@/
|
||
|
return unless @plain_text_body =~ /^(---$|diff -|Index: )/
|
||
|
@plain_text_body = $`
|
||
|
email.attachments['patch.diff'] = {
|
||
|
:mime_type => 'text/x-diff',
|
||
|
:content => email.to_s
|
||
|
}
|
||
|
end
|
||
|
end
|
||