Skip to content

Commit

Permalink
pin: fix first source fetch of local VCS pin done as a local non-VCS …
Browse files Browse the repository at this point in the history
…path
  • Loading branch information
rjbou committed Oct 1, 2024
1 parent e4e2b8b commit 5494923
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ users)
## Config

## Pin
* [BUG] Fix first retrieval of local VCS pin done as local path [#6221 @rjbou - fix #5809]

## List

Expand Down
15 changes: 6 additions & 9 deletions src/client/opamPinCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/reftests/fetch-package.test
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ 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:
=== install 1 package
- 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
Expand All @@ -128,15 +128,15 @@ 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:
=== install 1 package
- 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
Expand Down
5 changes: 3 additions & 2 deletions tests/reftests/pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
8 changes: 4 additions & 4 deletions tests/reftests/rec-pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5494923

Please sign in to comment.