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

Consistent accepted repository links #6091

Merged
merged 2 commits into from
Aug 9, 2024
Merged
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 @@ -42,6 +42,7 @@ users)

## Switch
* ◈ Add `opam switch import --deps-only` option to install only dependencies of root package at import [#5388 @rjbou - fix #5200]
* [BUG] Make accepted `--repos` URLs on creation consistent with `opam repository` [#6091 @Keryan-dev - fix #4673]

## Config

Expand Down
19 changes: 11 additions & 8 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,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 @@ -2574,9 +2574,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 ~handle_suffix:false ~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 @@ -2720,9 +2721,11 @@ let switch cli =
This scans the current directory for package definitions, chooses a \
compatible compiler, creates a local switch and installs the local \
package dependencies.";
`Pre " opam switch create trunk --repos \
default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git \
ocaml-variants.4.10.0+trunk";
`Pre (Printf.sprintf
" opam switch create trunk --repos \
default,beta=%shttps://github.com/ocaml/ocaml-beta-repository.git \
ocaml-variants.4.10.0+trunk"
(if OpamCLIVersion.Op.(cli @>= cli2_3) then "" else "git+"));
`P "Create a new switch called \"trunk\", with \
$(b,ocaml-variants.4.10.0+trunk) as compiler, with a new $(i,beta) \
repository bound to the given URL selected besides the default one."
Expand Down Expand Up @@ -2869,7 +2872,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 @@ -2909,7 +2912,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 @@ -2999,7 +3002,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
10 changes: 10 additions & 0 deletions tests/reftests/switch-creation.test
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ The following actions will be performed:
Done.
### cat $OPAMROOT/undef-switch/lib/prefix
${BASEDIR}/OPAM/undef-switch
### # switch with repo link
### # expects a warning, useful to check chosen backend
### opam switch create w-repo --repositories=from-link=https://github.com/ocaml/opam-repository.git --dry-run --empty
kit-ty-kate marked this conversation as resolved.
Show resolved Hide resolved
Creating repository from-link...
[from-link] Initialised
[WARNING] The repository 'from-link' at git+https://github.com/ocaml/opam-repository.git doesn't have a 'repo' file, and might not be compatible with this version of opam.
[NOTE] Repository at git+https://github.com/ocaml/opam-repository.git doesn't define its version, assuming it's 1.2.

<><> Upgrading repositories from older opam format ><><><><><><><><><><><><><><>
Upgrading repository "from-link"...
Loading