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 committed Mar 11, 2024
1 parent 2706f5f commit b7a875f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1192,10 +1192,25 @@ 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)) ->
TODO: here the version string is not a version but an error message
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_descr_body
(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), `Geq, 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 b7a875f

Please sign in to comment.