Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opam upgrade: Do not show the not-up-to-date message with packages tagged with avoid-version #6273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it worth working on the set of version instead of package one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it simplifies the code greatly. Otherwise we would need to have an intermediate map of set and update it

let latest =
OpamPackage.Set.fold (fun pkg latest ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable named pkg and the one defined 4 lines above are not the "same package" but have the same name, this can be misleading when reading the code.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should expand the default case, like that if we add another flag and this part is concerned there is an highlight.

(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
Loading