diff --git a/master_changes.md b/master_changes.md index 80d30f9438f..14ea1a5b9c4 100644 --- a/master_changes.md +++ b/master_changes.md @@ -34,6 +34,7 @@ users) ## Config ## Pin + * [BUG] Fix first retrieval of local VCS pin done as local path [#6221 @rjbou - fix #5809] ## List diff --git a/src/client/opamPinCommand.ml b/src/client/opamPinCommand.ml index 8432d06498b..0dfa97051d3 100644 --- a/src/client/opamPinCommand.ml +++ b/src/client/opamPinCommand.ml @@ -75,18 +75,15 @@ let get_source_definition ?version ?subpath ?locked st nv url = opam in let open OpamProcess.Job.Op in - let url = - let u = OpamFile.URL.url url in - match OpamUrl.local_dir u, u.OpamUrl.backend with - | Some dir, #OpamUrl.version_control -> - OpamFile.URL.with_url - (OpamUrl.of_string (OpamFilename.Dir.to_string dir)) - url - | _, _ -> url - in OpamUpdate.fetch_dev_package url srcdir ?subpath nv @@| function | Not_available (_,s) -> raise (Fetch_Fail s) | Up_to_date _ | Result _ -> + let srcdir = + let u = OpamFile.URL.url url in + match OpamUrl.local_dir u, u.OpamUrl.backend with + | Some dir, #OpamUrl.version_control -> dir + | _, _ -> srcdir + in let srcdir = OpamFilename.SubPath.(srcdir /? subpath) in match OpamPinned.find_opam_file_in_source ?locked nv.name srcdir with | None -> None diff --git a/tests/reftests/fetch-package.test b/tests/reftests/fetch-package.test index 4e3202539c7..cb88b48216a 100644 --- a/tests/reftests/fetch-package.test +++ b/tests/reftests/fetch-package.test @@ -109,7 +109,7 @@ opam root.ml ### opam pin foo-git-pin ./a-dev -y Package foo-git-pin does not exist, create as a NEW package? [y/n] y -[foo-git-pin.dev] synchronised (file://${BASEDIR}/a-dev) +[foo-git-pin.dev] synchronised (git+file://${BASEDIR}/a-dev#master) foo-git-pin is now pinned to git+file://${BASEDIR}/a-dev#master (version dev) The following actions will be performed: @@ -117,7 +117,7 @@ The following actions will be performed: - install foo-git-pin dev (pinned) <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> retrieved foo-git-pin.dev (git+file://${BASEDIR}/a-dev#master) +-> retrieved foo-git-pin.dev (no changes) -> installed foo-git-pin.dev Done. ### cat OPAM/downloads-pin/lib/foo-git-pin-files | sort @@ -128,7 +128,7 @@ root.ml ### :: dev-repo ### opam switch create downloads-devrepo --empty ### opam pin foo-git --dev-repo -y -[foo-git.1] synchronised (file://${BASEDIR}/a-dev) +[foo-git.1] synchronised (git+file://${BASEDIR}/a-dev) foo-git is now pinned to git+file://${BASEDIR}/a-dev (version 1) The following actions will be performed: @@ -136,7 +136,7 @@ The following actions will be performed: - install foo-git 1 (pinned) <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> retrieved foo-git.1 (git+file://${BASEDIR}/a-dev) +-> retrieved foo-git.1 (no changes) -> installed foo-git.1 Done. ### cat OPAM/downloads-devrepo/lib/foo-git-files | sort diff --git a/tests/reftests/pin.test b/tests/reftests/pin.test index 9200b996163..bb2c395b8e7 100644 --- a/tests/reftests/pin.test +++ b/tests/reftests/pin.test @@ -89,7 +89,7 @@ Now run 'opam upgrade' to apply any package updates. ### : pin with url ### opam pin add nip-git git+file://$BASEDIR/nip-git Package nip-git does not exist, create as a NEW package? [y/n] y -[nip-git.dev] synchronised (file://${BASEDIR}/nip-git) +[nip-git.dev] synchronised (git+file://${BASEDIR}/nip-git#master) nip-git is now pinned to git+file://${BASEDIR}/nip-git#master (version ved) The following actions will be performed: @@ -1381,9 +1381,10 @@ opam-version: "2.0" build: "false" ### opam pin vcs-local ./vcs-local --no-action Package vcs-local does not exist, create as a NEW package? [y/n] y -[vcs-local.dev] synchronised (file://${BASEDIR}/vcs-local) +[vcs-local.dev] synchronised (git+file://${BASEDIR}/vcs-local#master) vcs-local is now pinned to git+file://${BASEDIR}/vcs-local#master (version dev) ### test -f OPAM/vcs-local/.opam-switch/sources/vcs-local/untracked +# Return code 1 # ### opam show vcs-local --field build:,url.src: build: "false" url.src: "git+file://${BASEDIR}/vcs-local#master" diff --git a/tests/reftests/rec-pin.test b/tests/reftests/rec-pin.test index db265035002..2be8a534a3f 100644 --- a/tests/reftests/rec-pin.test +++ b/tests/reftests/rec-pin.test @@ -536,13 +536,13 @@ Package root-a-i-j_g does not exist, create as a NEW package? [y/n] y [root-a-i-j_g.3] synchronised (no changes) root-a-i-j_g is now subpath-pinned to directory /a/i/j in git+file://${BASEDIR}/pinnes#master (version 3) Package root-a-i_g does not exist, create as a NEW package? [y/n] y -[root-a-i_g.3] synchronised (directory /a/i in file://${BASEDIR}/pinnes) +[root-a-i_g.3] synchronised (no changes) root-a-i_g is now subpath-pinned to directory /a/i in git+file://${BASEDIR}/pinnes#master (version 3) Package root-a_p does not exist, create as a NEW package? [y/n] y [root-a_p.3] synchronised (no changes) root-a_p is now subpath-pinned to directory /a in file://${BASEDIR}/pinnes (version 3) Package root_g does not exist, create as a NEW package? [y/n] y -[root_g.3] synchronised (file://${BASEDIR}/pinnes) +[root_g.3] synchronised (no changes) root_g is now pinned to git+file://${BASEDIR}/pinnes#master (version 3) Package root-a-k_p does not exist, create as a NEW package? [y/n] y [root-a-k_p.3] synchronised (no changes) @@ -1052,13 +1052,13 @@ Package root-a-i-j_g does not exist, create as a NEW package? [y/n] y [root-a-i-j_g.3] synchronised (no changes) root-a-i-j_g is now subpath-pinned to directory /a/i/j in git+file://${BASEDIR}/pinnes#master (version 3) Package root-a-i_g does not exist, create as a NEW package? [y/n] y -[root-a-i_g.3] synchronised (directory /a/i in file://${BASEDIR}/pinnes) +[root-a-i_g.3] synchronised (no changes) root-a-i_g is now subpath-pinned to directory /a/i in git+file://${BASEDIR}/pinnes#master (version 3) Package root-a_p does not exist, create as a NEW package? [y/n] y [root-a_p.3] synchronised (no changes) root-a_p is now subpath-pinned to directory /a in file://${BASEDIR}/pinnes (version 3) Package root_g does not exist, create as a NEW package? [y/n] y -[root_g.3] synchronised (file://${BASEDIR}/pinnes) +[root_g.3] synchronised (no changes) root_g is now pinned to git+file://${BASEDIR}/pinnes#master (version 3) Package root-a-k_p does not exist, create as a NEW package? [y/n] y [root-a-k_p.3] synchronised (no changes)