Skip to content

Commit

Permalink
CLI version guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Keryan-dev committed Jul 16, 2024
1 parent 7c75fd2 commit fd78481
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2546,7 +2546,7 @@ let repository cli =
(* From a list of strings (either "repo_name" or "repo_name=URL"), configure the
repos with URLs if possible, and return the updated repos_state and selection of
repositories *)
let with_repos_rt gt repos f =
let with_repos_rt gt cli repos f =
OpamRepositoryState.with_ `Lock_none gt @@ fun rt ->
let repos, rt =
match repos with
Expand All @@ -2563,9 +2563,10 @@ let with_repos_rt gt repos f =
OpamStd.List.filter_map (function
| (_, None) -> None
| (n, Some url) ->
let handle_suffix = OpamCLIVersion.Op.(cli @>= cli2_3) in
let repo =
OpamStd.Option.Op.(
OpamUrl.parse_opt ~from_file:false url
OpamUrl.parse_opt ~handle_suffix ~from_file:false url
>>| fun u -> n, u)
in
if repo = None then
Expand Down Expand Up @@ -2857,7 +2858,7 @@ let switch cli =
`Ok ()
| Some `list_available, pattlist ->
OpamGlobalState.with_ `Lock_none @@ fun gt ->
with_repos_rt gt repos @@ fun (repos, rt) ->
with_repos_rt gt cli repos @@ fun (repos, rt) ->
let compilers = OpamSwitchCommand.get_compiler_packages ?repos rt in
let st = OpamSwitchState.load_virtual ?repos_list:repos gt rt in
OpamConsole.msg "# Listing available compilers from repositories: %s\n"
Expand Down Expand Up @@ -2897,7 +2898,7 @@ let switch cli =
`Ok ()
| Some `install, switch_arg::params ->
OpamGlobalState.with_ `Lock_write @@ fun gt ->
with_repos_rt gt repos @@ fun (repos, rt) ->
with_repos_rt gt cli repos @@ fun (repos, rt) ->
let switch = OpamSwitch.of_string switch_arg in
let use_local =
not no_install && not empty && OpamSwitch.is_external switch
Expand Down Expand Up @@ -2987,7 +2988,7 @@ let switch cli =
else Some (OpamFile.make (OpamFilename.of_string filename))
in
if is_new_switch then
with_repos_rt gt repos @@ fun (repos, rt) ->
with_repos_rt gt cli repos @@ fun (repos, rt) ->
let synopsis = "Import from " ^ Filename.basename filename in
let (), gt =
OpamGlobalState.with_write_lock gt @@ fun gt ->
Expand Down

0 comments on commit fd78481

Please sign in to comment.