Skip to content

Commit

Permalink
fixup proposal: stop overriding the opam file with local copy on vcs …
Browse files Browse the repository at this point in the history
…repos
  • Loading branch information
kit-ty-kate committed Mar 8, 2025
1 parent 44436b3 commit 413eee3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
29 changes: 2 additions & 27 deletions src/client/opamPinCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,17 @@ exception Fetch_Fail of string

let get_source_definition ?version ?subpath ?locked st nv url =
let root = st.switch_global.root in
let internal_pindir = OpamPath.Switch.pinned_package root st.switch nv.name in
let srcdir = OpamPath.Switch.pinned_package root st.switch nv.name in
let fix opam =
let opam = OpamFile.OPAM.with_url url opam in
match version with
| Some v -> OpamFile.OPAM.with_version v opam
| None -> opam
in
let open OpamProcess.Job.Op in
OpamUpdate.fetch_dev_package url internal_pindir ?subpath nv @@+ function
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 u.OpamUrl.backend with
| #OpamUrl.version_control ->
(match OpamUrl.local_dir u with
| Some dir ->
let get_branch d =
let url = OpamUrl.of_string (OpamFilename.Dir.to_string d) in
OpamRepository.revision d
{ url with
OpamUrl.transport = u.transport;
backend = u.backend }
in
get_branch dir @@+ fun local_branch ->
get_branch internal_pindir @@| fun distant_branch ->
(match local_branch, distant_branch with
| Some l, Some d when String.equal l d -> dir
| Some _, Some _ -> internal_pindir
| None, Some _ -> internal_pindir
| Some _, None -> dir
| None, None -> dir)
| None -> Done internal_pindir)
| `http | `rsync -> Done internal_pindir
in
srcdir @@| fun srcdir ->
let srcdir = OpamFilename.SubPath.(srcdir /? subpath) in
match OpamPinned.find_opam_file_in_source ?locked nv.name srcdir with
| None -> None
Expand Down
2 changes: 1 addition & 1 deletion tests/reftests/pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ 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"
build:
url.src: "git+file://${BASEDIR}/vcs-local#master"
### :C:b: double pinning when the opam file is opam/opam
### <pin:double/opam/opam>
Expand Down

0 comments on commit 413eee3

Please sign in to comment.