From 891aa882ef78ac1048c194885ee8a8241defc4a0 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Mon, 7 Nov 2022 17:45:23 +0100 Subject: [PATCH 1/3] compare view: remove empty headings (starting with 0), restructure code --- lib/views.ml | 132 +++++++++++++++------------------------------------ 1 file changed, 37 insertions(+), 95 deletions(-) diff --git a/lib/views.ml b/lib/views.ml index de33ccd..61af562 100644 --- a/lib/views.ml +++ b/lib/views.ml @@ -862,6 +862,42 @@ let compare_builds ~pkg_diff:(added_pkgs, removed_pkgs, changed_pkgs) ~opam_diff:(opam_diff, version_diff, left, right, duniverse_content_diff, duniverse_left, duniverse_right) = + let items, data = + List.fold_left (fun (items, data) (id, txt, amount, code) -> + if amount = 0 then + items, data + else + H.li [ H.a ~a:[H.a_href id] [txtf "%d %s" amount txt] ] :: items, + data @ H.h3 ~a:[H.a_id id] [H.txt txt] :: code) + ([], []) + [ ("opam-packages-removed", "Opam packages removed", + OpamPackage.Set.cardinal left, [ H.code (packages left) ]) ; + ("opam-packages-installede", "New opam packages installed", + OpamPackage.Set.cardinal right, [ H.code (packages right) ]) ; + ("opam-packages-version-diff", "Opam packages with version changes", + List.length version_diff, [ H.code (package_diffs version_diff) ]) ; + ("duniverse-packages-removed", "Duniverse packages removed", + List.length duniverse_left, [ H.code (duniverse_dirs duniverse_left) ]) ; + ("duniverse-packages-installed", "New duniverse packages installed", + List.length duniverse_right, [ H.code (duniverse_dirs duniverse_right) ]) ; + ("duniverse-packages-version-diff", "Duniverse packages with version changes", + List.length duniverse_content_diff, [ H.code (duniverse_diffs duniverse_content_diff) ]) ; + ("#opam-packages-opam-diff", "Opam packages with changes in their opam file", + List.length opam_diff, opam_diffs opam_diff) ; + ("env-removed", "Environment variables removed", + List.length removed_env, [ H.code (key_values removed_env) ]) ; + ("env-added", "New environment variables added", + List.length added_env, [ H.code (key_values added_env) ]) ; + ("env-changed", "Environment variables changed", + List.length changed_env, [ H.code (key_value_changes changed_env) ]) ; + ("pkgs-removed", "System packages removed", + List.length removed_pkgs, [ H.code (key_values removed_pkgs) ]) ; + ("pkgs-added", "New system packages added", + List.length added_pkgs, [ H.code (key_values added_pkgs) ]) ; + ("pkgs-changed", "System packages changed", + List.length changed_pkgs, [ H.code (key_value_changes changed_pkgs) ]) ; + ] + in layout ~nav:(`Comparison ((job_left, build_left), (job_right, build_right))) ~title:(Fmt.str "Comparing builds %a and %a" @@ -893,101 +929,7 @@ let compare_builds ~left:build_right.uuid ~right:build_left.uuid () ] [H.txt "Compare in reverse direction"]] ; - H.ul [ - H.li [ - H.a ~a:H.[a_href "#opam-packages-removed"] - [txtf "%d opam packages removed" - (OpamPackage.Set.cardinal left)] - ]; - H.li [ - H.a ~a:H.[a_href "#opam-packages-installed"] - [txtf "%d new opam packages installed" - (OpamPackage.Set.cardinal right)] - ]; - H.li [ - H.a ~a:H.[a_href "#opam-packages-version-diff"] - [txtf "%d opam packages with version changes" - (List.length version_diff)] - ]; - H.li [ - H.a ~a:H.[a_href "#duniverse-packages-removed"] - [txtf "%d duniverse packages removed" - (List.length duniverse_left)] - ]; - H.li [ - H.a ~a:H.[a_href "#duniverse-packages-installed"] - [txtf "%d new duniverse packages installed" - (List.length duniverse_right)] - ]; - H.li [ - H.a ~a:H.[a_href "#duniverse-packages-version-diff"] - [txtf "%d duniverse packages with version changes" - (List.length duniverse_content_diff)] - ]; - H.li [ - H.a ~a:H.[a_href "#opam-packages-opam-diff"] - [txtf "%d opam packages with changes in their opam file" - (List.length opam_diff)] - ]; - H.li [ - H.a ~a:H.[a_href "#env-added"] - [ txtf "%d environment variables added" (List.length added_env)] - ]; - H.li [ - H.a ~a:H.[a_href "#env-removed"] - [ txtf "%d environment variables removed" (List.length removed_env)] - ]; - H.li [ - H.a ~a:H.[a_href "#env-changed"] - [ txtf "%d environment variables changed" (List.length changed_env)] - ]; - H.li [ - H.a ~a:H.[a_href "#pkgs-added"] - [ txtf "%d system packages added" (List.length added_pkgs)] - ]; - H.li [ - H.a ~a:H.[a_href "#pkgs-removed"] - [ txtf "%d system packages removed" (List.length removed_pkgs)] - ]; - H.li [ - H.a ~a:H.[a_href "#pkgs-changed"] - [ txtf "%d system packages changed" (List.length changed_pkgs)] - ]; - ]; - H.h3 ~a:H.[a_id "opam-packages-removed"] - [H.txt "Opam packages removed"]; - H.code (packages left); - H.h3 ~a:H.[a_id "opam-packages-installed"] - [H.txt "New opam packages installed"]; - H.code (packages right); - H.h3 ~a:H.[a_id "opam-packages-version-diff"] - [H.txt "Opam packages with version changes"]; - H.code (package_diffs version_diff); - H.h3 ~a:H.[a_id "duniverse-dirs-removed"] - [H.txt "Duniverse directories removed"]; - H.code (duniverse_dirs duniverse_left); - H.h3 ~a:H.[a_id "duniverse-dirs-installed"] - [H.txt "New Duniverse directories installed"]; - H.code (duniverse_dirs duniverse_right); - H.h3 ~a:H.[a_id "duniverse-dirs-version-diff"] - [H.txt "Duniverse directories with content changes"]; - H.code (duniverse_diffs duniverse_content_diff); - H.h3 ~a:H.[a_id "opam-packages-opam-diff"] - [H.txt "Opam packages with changes in their opam file"]] @ - opam_diffs opam_diff @ [ - H.h3 ~a:H.[a_id "env-added"] [H.txt "Environment variables added"]; - H.code (key_values added_env); - H.h3 ~a:H.[a_id "env-removed"] [H.txt "Environment variables removed"]; - H.code (key_values removed_env); - H.h3 ~a:H.[a_id "env-changed"] [H.txt "Environment variables changed"]; - H.code (key_value_changes changed_env); - H.h3 ~a:H.[a_id "pkgs-added"] [H.txt "System packages added"]; - H.code (key_values added_pkgs); - H.h3 ~a:H.[a_id "pkgs-removed"] [H.txt "System packages removed"]; - H.code (key_values removed_pkgs); - H.h3 ~a:H.[a_id "pkgs-changed"] [H.txt "System packages changed"]; - H.code (key_value_changes changed_pkgs); - ]) + H.ul (List.rev items) ] @ data) let failed_builds ~start ~count builds = let build (job_name, build) = From 2f632fc4c35f7317ba8342c63900af1ee3cba4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Tue, 8 Nov 2022 10:06:48 +0100 Subject: [PATCH 2/3] duniverse package, version -> dir, content See previous recent nomenclature commit --- lib/views.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/views.ml b/lib/views.ml index 61af562..08e8ecb 100644 --- a/lib/views.ml +++ b/lib/views.ml @@ -876,11 +876,11 @@ let compare_builds OpamPackage.Set.cardinal right, [ H.code (packages right) ]) ; ("opam-packages-version-diff", "Opam packages with version changes", List.length version_diff, [ H.code (package_diffs version_diff) ]) ; - ("duniverse-packages-removed", "Duniverse packages removed", + ("duniverse-dirs-removed", "Duniverse directories removed", List.length duniverse_left, [ H.code (duniverse_dirs duniverse_left) ]) ; - ("duniverse-packages-installed", "New duniverse packages installed", + ("duniverse-dirs-installed", "New duniverse directories installed", List.length duniverse_right, [ H.code (duniverse_dirs duniverse_right) ]) ; - ("duniverse-packages-version-diff", "Duniverse packages with version changes", + ("duniverse-dirs-content-diff", "Duniverse directories with content changes", List.length duniverse_content_diff, [ H.code (duniverse_diffs duniverse_content_diff) ]) ; ("#opam-packages-opam-diff", "Opam packages with changes in their opam file", List.length opam_diff, opam_diffs opam_diff) ; From 5722fccf316e5682233299ed5872290120f074ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Tue, 8 Nov 2022 10:09:06 +0100 Subject: [PATCH 3/3] Fix local hrefs The id attribute needs the id name without '#' while in the anchor href we need to prefix with '#'. --- lib/views.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/views.ml b/lib/views.ml index 08e8ecb..116e149 100644 --- a/lib/views.ml +++ b/lib/views.ml @@ -864,10 +864,11 @@ let compare_builds = let items, data = List.fold_left (fun (items, data) (id, txt, amount, code) -> + let id_href = "#" ^ id in if amount = 0 then items, data else - H.li [ H.a ~a:[H.a_href id] [txtf "%d %s" amount txt] ] :: items, + H.li [ H.a ~a:[H.a_href id_href] [txtf "%d %s" amount txt] ] :: items, data @ H.h3 ~a:[H.a_id id] [H.txt txt] :: code) ([], []) [ ("opam-packages-removed", "Opam packages removed", @@ -882,7 +883,7 @@ let compare_builds List.length duniverse_right, [ H.code (duniverse_dirs duniverse_right) ]) ; ("duniverse-dirs-content-diff", "Duniverse directories with content changes", List.length duniverse_content_diff, [ H.code (duniverse_diffs duniverse_content_diff) ]) ; - ("#opam-packages-opam-diff", "Opam packages with changes in their opam file", + ("opam-packages-opam-diff", "Opam packages with changes in their opam file", List.length opam_diff, opam_diffs opam_diff) ; ("env-removed", "Environment variables removed", List.length removed_env, [ H.code (key_values removed_env) ]) ;