Skip to content

Commit d4d1bfa

Browse files
committed
use 'opam --version' to get the opam version (instead of reading env)
1 parent 77cbdd0 commit d4d1bfa

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.travis-docker.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ echo -en "travis_fold:start:prepare.ci\r"
55
default_user=ocaml
66
default_branch=master
77
default_hub_user=ocaml
8-
default_opam_version=1.2.0
8+
default_opam_version=2.0.0
99

1010
fork_user=${FORK_USER:-$default_user}
1111
fork_branch=${FORK_BRANCH:-$default_branch}

src/ci_opam.ml

+8-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ let revdep_run = list (getenv_default "REVDEPS" "")
6161
let opam_lint = fuzzy_bool_of_string (getenv_default "OPAM_LINT" "true")
6262

6363
(* opam version *)
64-
let opam_version = getenv_default "OPAM_VERSION" "2.0.0"
64+
let opam_version =
65+
let raw = ?|> "opam --version" in
66+
match if String.length raw <= 1 then '?' else raw.[0] with
67+
| '2' -> `V2
68+
| '1' -> `V1
69+
| _ -> failwith (raw ^ ": invalid opam version")
6570

6671
(* other variables *)
6772
let extra_deps = list (getenv_default "EXTRA_DEPS" "")
@@ -252,8 +257,8 @@ with_fold "Prepare" (fun () ->
252257
in
253258

254259
(if opam_lint then match opam_version with
255-
| "2.0.0" -> ?|~ "opam lint %s --warn=-21-32-48" opam
256-
| _ -> ?|~ "opam lint %s" opam);
260+
| `V2 -> ?|~ "opam lint %s --warn=-21-32-48" opam
261+
| _ -> ?|~ "opam lint %s" opam);
257262
let pins = lint_pins pkg pins in
258263
List.iter pin pins;
259264
?| "eval $(opam config env)";

0 commit comments

Comments
 (0)