Packages w/ same version different opam

This commit is contained in:
Reynir Björnsson 2021-02-12 12:18:41 +01:00
parent ac43298620
commit c51399823c
3 changed files with 25 additions and 10 deletions

View file

@ -277,7 +277,7 @@ let routes t =
| Ok (switch_left, _sha256_left), Ok (switch_right, _sha256_right) -> | Ok (switch_left, _sha256_left), Ok (switch_right, _sha256_right) ->
let switch_left = OpamFile.SwitchExport.read_from_string switch_left let switch_left = OpamFile.SwitchExport.read_from_string switch_left
and switch_right = OpamFile.SwitchExport.read_from_string switch_right in and switch_right = OpamFile.SwitchExport.read_from_string switch_right in
Opamdiff.compare (Opamdiff.packages switch_left) (Opamdiff.packages switch_right) Opamdiff.compare switch_left switch_right
|> Views.compare_opam build_left build_right |> Views.compare_opam build_left build_right
|> Response.of_html |> Response.of_html
in in

View file

@ -226,7 +226,7 @@ let package_diffs diffs =
]) ])
diffs diffs
let compare_opam build_left build_right (same, version_diff, left, right) = let compare_opam build_left build_right (same, opam_diff, version_diff, left, right) =
layout ~title:(Fmt.strf "Comparing opam switches between builds %a and %a" layout ~title:(Fmt.strf "Comparing opam switches between builds %a and %a"
Uuidm.pp build_left Uuidm.pp build_right) Uuidm.pp build_left Uuidm.pp build_right)
[ [
@ -245,9 +245,13 @@ let compare_opam build_left build_right (same, version_diff, left, right) =
[txtf "%d new packages installed" (OpamPackage.Set.cardinal right)] [txtf "%d new packages installed" (OpamPackage.Set.cardinal right)]
]; ];
li [ li [
a ~a:[a_href "#packages-diff"] a ~a:[a_href "#packages-version-diff"]
[txtf "%d packages with version changes" (List.length version_diff)] [txtf "%d packages with version changes" (List.length version_diff)]
]; ];
li [
a ~a:[a_href "#packages-opam-diff"]
[txtf "%d packages with changes in their opam file" (OpamPackage.Set.cardinal opam_diff)]
];
li [ li [
a ~a:[a_href "#packages-unchanged"] a ~a:[a_href "#packages-unchanged"]
[txtf "%d packages unchanged" (OpamPackage.Set.cardinal same)] [txtf "%d packages unchanged" (OpamPackage.Set.cardinal same)]
@ -259,9 +263,12 @@ let compare_opam build_left build_right (same, version_diff, left, right) =
h3 ~a:[a_id "packages-installed"] h3 ~a:[a_id "packages-installed"]
[txt "New packages installed"]; [txt "New packages installed"];
code (packages right); code (packages right);
h3 ~a:[a_id "packages-diff"] h3 ~a:[a_id "packages-version-diff"]
[txt "Packages with version changes"]; [txt "Packages with version changes"];
code (package_diffs version_diff); code (package_diffs version_diff);
h3 ~a:[a_id "packages-opam-diff"]
[txt "Packages with changes in their opam file"];
code (packages opam_diff);
h3 ~a:[a_id "packages-unchanged"] h3 ~a:[a_id "packages-unchanged"]
[txt "Unchanged packages"]; [txt "Unchanged packages"];
code (packages same); code (packages same);

View file

@ -24,6 +24,7 @@ let pp_version_diff ppf { name; version_left; version_right } =
(OpamPackage.Version.to_string version_right) (OpamPackage.Version.to_string version_right)
let compare left right = let compare left right =
let packages_left = packages left and packages_right = packages right in
let module Set = OpamPackage.Set in let module Set = OpamPackage.Set in
let equal_name p1 p2 = OpamPackage.Name.equal p1.OpamPackage.name p2.OpamPackage.name in let equal_name p1 p2 = OpamPackage.Name.equal p1.OpamPackage.name p2.OpamPackage.name in
let diff l r = let diff l r =
@ -31,10 +32,17 @@ let compare left right =
not (Set.exists (equal_name p1) r)) not (Set.exists (equal_name p1) r))
l l
in in
let same = Set.inter left right let same_version = Set.inter packages_left packages_right in
let (same, opam_diff) =
Set.partition
(fun p ->
let find = OpamPackage.Name.Map.find p.name in
let opam_left = find left.overlays and opam_right = find right.overlays in
OpamFile.OPAM.effectively_equal opam_left opam_right)
same_version
and version_diff = and version_diff =
List.filter_map (fun p1 -> List.filter_map (fun p1 ->
match Set.find_opt (equal_name p1) right with match Set.find_opt (equal_name p1) packages_right with
| Some p2 -> | Some p2 ->
if OpamPackage.Version.equal p1.version p2.version if OpamPackage.Version.equal p1.version p2.version
then None then None
@ -44,8 +52,8 @@ let compare left right =
version_right = p2.OpamPackage.version } version_right = p2.OpamPackage.version }
| None -> | None ->
None) None)
(Set.elements left) (Set.elements packages_left)
and left = diff left right and left = diff packages_left packages_right
and right = diff right left and right = diff packages_right packages_left
in in
(same, version_diff, left, right) (same, opam_diff, version_diff, left, right)