From 369bf57973c59882881c14d7754e7cad9a3acc4e Mon Sep 17 00:00:00 2001 From: Caroline Russell Date: Sun, 4 Aug 2024 21:26:01 -0400 Subject: [PATCH] Fix html report bug. Signed-off-by: Caroline Russell --- custom_json_diff/bom_diff_template.j2 | 4 ++-- custom_json_diff/custom_diff.py | 5 +++-- custom_json_diff/custom_diff_classes.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/custom_json_diff/bom_diff_template.j2 b/custom_json_diff/bom_diff_template.j2 index 3314d0a..415a92b 100644 --- a/custom_json_diff/bom_diff_template.j2 +++ b/custom_json_diff/bom_diff_template.j2 @@ -96,7 +96,7 @@ {{ bom_1 }} {{ bom_2 }} - {% if not (diff_apps_1 or diff_apps_2 or diff_frameworks_1 or diff_frameworks_2 or diff_lib_1 or diff_lib_2 or diff_other_1 or diff_other_2 or diff_vdrs_1 or diff_vdrs_2) %} + {% if diff_status == 0 %} No differences found. @@ -432,7 +432,7 @@ Components - {% if not (common_apps or common_frameworks or common_lib or common_other) %} + {% if not (common_apps or common_frameworks or common_lib or common_other or common_services or common_deps or common_vdrs) %} No commonalities. diff --git a/custom_json_diff/custom_diff.py b/custom_json_diff/custom_diff.py index 6d83f34..35527b8 100644 --- a/custom_json_diff/custom_diff.py +++ b/custom_json_diff/custom_diff.py @@ -43,7 +43,7 @@ def compare_dicts(options: Options) -> Tuple[int, FlatDicts | BomDicts, FlatDict return 1, json_1_data, json_2_data -def export_html_report(outfile: str, diffs: Dict, j1: BomDicts, j2: BomDicts, options: Options) -> None: +def export_html_report(outfile: str, diffs: Dict, j1: BomDicts, j2: BomDicts, options: Options, status: int) -> None: if options.report_template: template_file = options.report_template else: @@ -92,6 +92,7 @@ def export_html_report(outfile: str, diffs: Dict, j1: BomDicts, j2: BomDicts, op stats=stats_summary, comp_only=options.comp_only, metadata=metadata_results, + diff_status=status, ) with open(outfile, "w", encoding="utf-8") as f: f.write(report_result) @@ -178,7 +179,7 @@ def report_results(status: int, diffs: Dict, options: Options, j1: BomDicts | No return if options.bom_diff: report_file = options.output.replace(".json", "") + ".html" - export_html_report(report_file, diffs, j1, j2, options) # type: ignore + export_html_report(report_file, diffs, j1, j2, options, status) # type: ignore def sort_dict_lists(result: Dict, sort_keys: List[str]) -> Dict: diff --git a/custom_json_diff/custom_diff_classes.py b/custom_json_diff/custom_diff_classes.py index 8dff555..d68ffed 100644 --- a/custom_json_diff/custom_diff_classes.py +++ b/custom_json_diff/custom_diff_classes.py @@ -454,7 +454,7 @@ def compare_date(dt1: str, dt2: str, comparator: str): def compare_vdr_new_versions(vdr_1: BomVdr, vdr_2: BomVdr) -> bool: return all((vdr_1.affects == vdr_2.affects, - compare_date(vdr_1.updated, vdr_2.updated, "<"), + (not vdr_1.updated or compare_date(vdr_1.updated, vdr_2.updated, "<=")), compare_bom_refs(vdr_1.bom_ref, vdr_2.bom_ref)))