Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: David Allsopp <david.allsopp@metastack.com>
  • Loading branch information
kit-ty-kate and dra27 authored Mar 11, 2024
1 parent b88b9a4 commit 9a675df
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1192,10 +1192,24 @@ let read_opam dir =
(OpamPp.string_of_bad_format (OpamPp.Bad_format (snd err)));
None
| None, None -> None
| exception (OpamPp.Bad_version _bf) ->
log "opam-version unsupported on %s. Add as dummy unavailable package."
| exception (OpamPp.Bad_version (_, version) ->
log "opam-version %S unsupported on %s. Added as dummy unavailable package." version
(OpamFile.to_string opam_file);
Some (OpamFile.OPAM.with_available (FBool false) OpamFile.OPAM.empty)
if OpamVersion.compare OpamVersion.current (OpamVersion.of_string version) >= 0 then begin
log "Unexpected failure: failed to parse version %S but is below the current version %S"
version (OpamVersion.to_string OpamVersion.current);
Some (OpamFile.OPAM.with_available (FBool false) OpamFile.OPAM.empty)
end else
Some
(OpamFile.OPAM.with_description
(Printf.sprintf
"This package uses opam 3.0 file format which opam 2.2 cannot read.\n\
\n\
In order to install or view information on this package, please upgrade your opam installation to at least version %s."
version)
(OpamFile.OPAM.with_available
(FOp (FIdent ([], OpamVariable.of_string "opam-version", None), `Ge, FString version))
OpamFile.OPAM.empty)

let read_repo_opam ~repo_name ~repo_root dir =
let open OpamStd.Option.Op in
Expand Down

0 comments on commit 9a675df

Please sign in to comment.