Skip to content

Commit

Permalink
Improve demote - move broken packages to the end
Browse files Browse the repository at this point in the history
  • Loading branch information
samoht committed Aug 28, 2023
1 parent d258d48 commit 8f5122a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/opam_solve.ml
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,19 @@ module Opam_monorepo_context (Base_context : BASE_CONTEXT) :
(version, Ok opam_file))

let demote_candidates_to_avoid versions =
let avoid_versions, regular_versions =
List.partition versions ~f:(fun (_version, opam_res) ->
let avoid_versions, broken_versions, regular_versions =
List.fold_left versions ~init:([], [], [])
~f:(fun (avoid, broken, regular) ((_, opam_res) as e) ->
match opam_res with
| Ok opam -> Opam.avoid_version opam
| Error _ -> false)
| Ok opam ->
if Opam.avoid_version opam then (e :: avoid, broken, regular)
else (avoid, broken, e :: regular)
| Error _ -> (avoid, e :: broken, regular))
in
regular_versions @ avoid_versions
List.rev_append regular_versions
@@ List.rev_append avoid_versions
(* we keep the broken versions to improve error messages *)
broken_versions

let promote_version version candidates =
match version with
Expand Down

0 comments on commit 8f5122a

Please sign in to comment.