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

Pin: fix first local vcs fetch rsyncing all source #6221

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 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 All @@ -50,6 +51,7 @@ users)
## Source

## Lint
* [BUG] fix lint W59 with local urls that are not archives [#6219 @rjbou - fix #6218]

## Repository

Expand Down Expand Up @@ -107,6 +109,9 @@ users)

## Reftests
### Tests
* Add more tests for lint W59 [#6219 @rjbou]
* More exhaustive test for pin command: test different behaviour and cli options [#6135 @rjbou]
* pin: add a test for erroneous first fetch done as local path on local VCS pinned packages [#6221 @rjbou]

### Engine

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
12 changes: 9 additions & 3 deletions src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,15 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t =
| #OpamUrl.version_control -> true
| _ -> false)
in
let url_archive =
let open OpamStd.Option.Op in
t.url >>| OpamFile.URL.url >>| (fun u ->
OpamSystem.is_archive u.OpamUrl.path)
in
let is_url_archive =
not (OpamFile.OPAM.has_flag Pkgflag_Conf t) &&
url_vcs = Some false
not (OpamFile.OPAM.has_flag Pkgflag_Conf t)
&& url_vcs = Some false
&& url_archive = Some true
in
let check_upstream = check_upstream && is_url_archive in
let check_double compare to_str lst =
Expand Down Expand Up @@ -1001,7 +1007,7 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t =
|> List.map OpamHash.to_string
|> OpamStd.Format.pretty_list)])
t.url)
(url_vcs = Some true
(url_vcs = Some true && url_archive = Some false
&& OpamStd.Option.Op.(t.url >>| fun u -> OpamFile.URL.checksum u <> [])
= Some true);
cond 68 `Warning
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
51 changes: 49 additions & 2 deletions tests/reftests/lint.test
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ ${BASEDIR}/lint.opam: Warnings.
### opam lint ./lint.opam --check-upstream
${BASEDIR}/lint.opam: Warnings.
warning 59: url doesn't contain a checksum
### # package with conf flag
### <lint.opam>
opam-version: "2.0"
synopsis: "A word"
Expand All @@ -864,7 +865,6 @@ dev-repo: "hg+https://[email protected]"
bug-reports: "https://nobug"
url { src:"an-archive.tgz" }
flags: conf
### # package with conf flag
### opam lint ./lint.opam
${BASEDIR}/lint.opam: Errors.
error 46: Package is flagged "conf" but has source, install or remove instructions
Expand All @@ -873,6 +873,7 @@ ${BASEDIR}/lint.opam: Errors.
${BASEDIR}/lint.opam: Errors.
error 46: Package is flagged "conf" but has source, install or remove instructions
# Return code 1 #
### # package with git url
### <lint.opam>
opam-version: "2.0"
synopsis: "A word"
Expand All @@ -884,7 +885,53 @@ license: "ISC"
dev-repo: "hg+https://[email protected]"
bug-reports: "https://nobug"
url { src:"git+https://a/repo" }
### # package with git url
### opam lint ./lint.opam
${BASEDIR}/lint.opam: Passed.
### opam lint ./lint.opam --check-upstream
${BASEDIR}/lint.opam: Passed.
### # package with local url
### <repo/stuff>
something
### <lint.opam>
opam-version: "2.0"
synopsis: "A word"
description: "Two words."
authors: "the testing team"
homepage: "egapemoh"
maintainer: "[email protected]"
license: "ISC"
dev-repo: "hg+https://[email protected]"
bug-reports: "https://nobug"
### <add-url.sh>
basedir=$(echo $BASEDIR | sed "s/\\\\\\\\/\\\\\\\\\\\\\\\\/g")
cat << EOF >> lint.opam
url { src:"file://$basedir/an-archive" }
EOF
### sh add-url.sh
### opam lint ./lint.opam
${BASEDIR}/lint.opam: Passed.
### opam lint ./lint.opam --check-upstream
${BASEDIR}/lint.opam: Passed.
### # package with local archive url
### <lint.opam>
opam-version: "2.0"
synopsis: "A word"
description: "Two words."
authors: "the testing team"
homepage: "egapemoh"
maintainer: "[email protected]"
license: "ISC"
dev-repo: "hg+https://[email protected]"
bug-reports: "https://nobug"
### <add-url.sh>
basedir=$(echo $BASEDIR | sed "s/\\\\\\\\/\\\\\\\\\\\\\\\\/g")
cat << EOF >> lint.opam
url {
src:"file://$basedir/an-archive.tgz"
checksum: "md5=$(openssl md5 an-archive.tgz | cut -f2 -d' ')"
}
EOF
### sh add-url.sh
### opam lint ./lint.opam
${BASEDIR}/lint.opam: Passed.
### opam lint ./lint.opam --check-upstream
Expand Down
Loading
Loading