Skip to content

Commit

Permalink
opam upgrade: Do not show the not-up-to-date message with packages ta…
Browse files Browse the repository at this point in the history
…gged with avoid-version
  • Loading branch information
kit-ty-kate committed Oct 28, 2024
1 parent 2a57765 commit f810b2a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ users)
## UI
* [BUG] Fix the detection of the current terminal size [#6244 @kit-ty-kate - fix #6243]
* [BUG] Ensure the output of opam commands using a column style UI stay consistent accross environment by setting the number of columns to 80 if stdout is not a tty and if the `COLUMNS` env variable is not set [#6244 @kit-ty-kate]
* [BUG] opam upgrade: Do not show the not-up-to-date message with packages tagged with avoid-version [#6273 @kit-ty-kate - fix #6271]

## Switch

Expand Down
22 changes: 19 additions & 3 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,25 @@ let upgrade_t
else OpamPackage.packages_of_names t.installed requested
in
let latest =
OpamPackage.Name.Set.fold (fun name acc ->
OpamPackage.Set.add (OpamPackage.max_version t.packages name) acc)
(OpamPackage.names_of_packages to_check)
OpamPackage.Set.fold (fun pkg acc ->
let name = OpamPackage.name pkg in
let pkgs = OpamPackage.packages_of_name t.packages name in
let latest =
OpamPackage.Set.fold (fun pkg latest ->
if OpamPackage.compare latest pkg < 0 then
let opam = OpamPackage.Map.find pkg t.opams in
let avoid_version =
List.exists (function
| Pkgflag_AvoidVersion | Pkgflag_Deprecated -> true
| _ -> false)
(OpamFile.OPAM.flags opam)
in
if avoid_version then latest else pkg
else latest)
pkgs pkg
in
OpamPackage.Set.add latest acc)
to_check
OpamPackage.Set.empty in
let notuptodate = latest -- to_check in
if OpamPackage.Set.is_empty notuptodate then
Expand Down

0 comments on commit f810b2a

Please sign in to comment.