@@ -220,54 +220,8 @@ def send_report(
220220 title = self ._message_formatter .format_report_title (
221221 report = report ,
222222 )
223-
224- if self .configuration .report_in_pdf :
225- return self ._send_report_in_pdf (
226- report = report ,
227- title = title ,
228- )
229-
230223 if len (title ) > _TITLE_MAX_SIZE :
231224 title = f"{ title [:_TITLE_MAX_SIZE - 3 ]} ..."
232- description = self ._message_formatter .format_report_description (
233- report = report ,
234- ) + self ._get_attachments_list_description (
235- title = "*Attachments*:" ,
236- item_template = self ._attachments_list_description_item_jira_template ,
237- attachments = report .attachments ,
238- unique_name_prefix = self ._report_attachment_name_prefix ,
239- )
240- markdown_description = ""
241- description_attachment = None
242- if len (description ) > _TEXT_MAX_SIZE :
243- description_attachment = self ._build_external_description_attachment (
244- name = f'report-{ report .local_id .replace ("#" , "" )} -description.md' ,
245- )
246- markdown_description = ReportMessageMarkdownFormatter ().format_report_description (
247- report = report ,
248- ) + self ._get_attachments_list_description (
249- title = "**Attachments**:" ,
250- item_template = self ._attachments_list_description_item_markdown_template ,
251- attachments = report .attachments ,
252- unique_name_prefix = self ._report_attachment_name_prefix ,
253- )
254- report_copy = deepcopy (report )
255- report_copy .description_html = (
256- "<p>This report description is too large to fit into a JIRA issue. "
257- + f'See attachment <a href="{ description_attachment .url } ">{ description_attachment .original_name } </a> '
258- + "for more details.</p>"
259- )
260- description = self ._message_formatter .format_report_description (
261- report = report_copy ,
262- ) + self ._get_attachments_list_description (
263- title = "*Attachments*:" ,
264- item_template = self ._attachments_list_description_item_jira_template ,
265- attachments = [
266- description_attachment ,
267- * report .attachments ,
268- ],
269- unique_name_prefix = self ._report_attachment_name_prefix ,
270- )
271225
272226 parent_issue = None
273227 if self .configuration .epic_creation_enabled :
@@ -282,56 +236,86 @@ def send_report(
282236 description = "This issue is being synchronized. Please check back in a moment." ,
283237 parent_id = parent_issue .key if parent_issue else None ,
284238 )
285- description , markdown_description = self ._replace_attachments_references (
286- uploads = self ._upload_attachments (
287- issue = jira_issue ,
239+
240+ if self .configuration .report_in_pdf :
241+ description = f"View report on YesWeHack: { report .report_url } "
242+ self ._attach_report_pdf (
243+ jira_issue = jira_issue ,
244+ report = report ,
245+ )
246+ else :
247+ description = self ._message_formatter .format_report_description (
248+ report = report ,
249+ ) + self ._get_attachments_list_description (
250+ title = "*Attachments*:" ,
251+ item_template = self ._attachments_list_description_item_jira_template ,
288252 attachments = report .attachments ,
289253 unique_name_prefix = self ._report_attachment_name_prefix ,
290- ),
291- referencing_texts = [
292- description ,
293- markdown_description ,
294- ],
295- unique_name_prefix = self ._report_attachment_name_prefix ,
296- )
297- if description_attachment :
298- description_attachment .data_loader = lambda : bytes (markdown_description , "utf-8" )
299- description = self ._replace_attachments_references (
300- uploads = self ._upload_attachments (
301- issue = jira_issue ,
254+ )
255+ markdown_description = ""
256+ description_attachment = None
257+ if len (description ) > _TEXT_MAX_SIZE :
258+ description_attachment = self ._build_external_description_attachment (
259+ name = f'report-{ report .local_id .replace ("#" , "" )} -description.md' ,
260+ )
261+ markdown_description = ReportMessageMarkdownFormatter ().format_report_description (
262+ report = report ,
263+ ) + self ._get_attachments_list_description (
264+ title = "**Attachments**:" ,
265+ item_template = self ._attachments_list_description_item_markdown_template ,
266+ attachments = report .attachments ,
267+ unique_name_prefix = self ._report_attachment_name_prefix ,
268+ )
269+ report_copy = deepcopy (report )
270+ report_copy .description_html = (
271+ "<p>This report description is too large to fit into a JIRA issue. "
272+ + f'See attachment <a href="{ description_attachment .url } ">{ description_attachment .original_name } '
273+ + "</a> for more details.</p>"
274+ )
275+ description = self ._message_formatter .format_report_description (
276+ report = report_copy ,
277+ ) + self ._get_attachments_list_description (
278+ title = "*Attachments*:" ,
279+ item_template = self ._attachments_list_description_item_jira_template ,
302280 attachments = [
303281 description_attachment ,
282+ * report .attachments ,
304283 ],
305284 unique_name_prefix = self ._report_attachment_name_prefix ,
285+ )
286+
287+ description , markdown_description = self ._replace_attachments_references (
288+ uploads = self ._upload_attachments (
289+ issue = jira_issue ,
290+ attachments = report .attachments ,
291+ unique_name_prefix = self ._report_attachment_name_prefix ,
306292 ),
307293 referencing_texts = [
308294 description ,
295+ markdown_description ,
309296 ],
310297 unique_name_prefix = self ._report_attachment_name_prefix ,
311- )[0 ]
298+ )
299+ if description_attachment :
300+ description_attachment .data_loader = lambda : bytes (markdown_description , "utf-8" )
301+ description = self ._replace_attachments_references (
302+ uploads = self ._upload_attachments (
303+ issue = jira_issue ,
304+ attachments = [
305+ description_attachment ,
306+ ],
307+ unique_name_prefix = self ._report_attachment_name_prefix ,
308+ ),
309+ referencing_texts = [
310+ description ,
311+ ],
312+ unique_name_prefix = self ._report_attachment_name_prefix ,
313+ )[0 ]
314+
312315 jira_issue .update (
313316 description = description ,
314317 )
315- return self ._build_tracker_issue (
316- issue_id = jira_issue .key ,
317- issue_url = jira_issue .permalink (), # type: ignore
318- closed = False ,
319- )
320318
321- def _send_report_in_pdf (
322- self ,
323- report : Report ,
324- title : str ,
325- ) -> TrackerIssue :
326- description = f"View report on YesWeHack: { report .report_url } "
327- jira_issue = self ._create_issue (
328- title = title ,
329- description = description ,
330- )
331- self ._attach_report_pdf (
332- jira_issue = jira_issue ,
333- report = report ,
334- )
335319 return self ._build_tracker_issue (
336320 issue_id = jira_issue .key ,
337321 issue_url = jira_issue .permalink (), # type: ignore
0 commit comments