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

Add warning when dev-repo is missing #362

Merged
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
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### Added

- Display warning when a package to be locked is missing a `dev-repo` field and
is being skipped because of it (#341, #362, @kit-ty-kate,
@Leonidas-from-XIV)

### Changed

### Deprecated
Expand Down
7 changes: 7 additions & 0 deletions lib/duniverse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ module Repo = struct
} ->
let* url = url url_src in
Ok (Some { opam = package; dev_repo; url; hashes })
| { dev_repo = None; package; _ } ->
Logs.warn (fun l ->
l
"Package %a has no dev-repo specified, but it needs a \
dev-repo to be successfully included in the duniverse."
Opam.Pp.package package);
Ok None
| _ -> Ok None)
end

Expand Down
3 changes: 2 additions & 1 deletion lib/opam.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,11 @@ module Package_summary = struct

let has_flag flag { flags; _ } = List.mem flag ~set:flags
let is_compiler v = has_flag OpamTypes.Pkgflag_Compiler v
let is_conf v = has_flag OpamTypes.Pkgflag_Conf v

let is_virtual = function
| { url_src = None; _ } -> true
| { dev_repo = None | Some ""; _ } -> true
| { dev_repo = None | Some ""; _ } as pkg when is_conf pkg -> true
| { build_commands = []; _ } -> true
| _ -> false

Expand Down
9 changes: 9 additions & 0 deletions test/bin/missing-dev-repo.t/missing-dev-repo.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
opam-version: "2.0"
depends: [
"dune"
"no-dev-repo"
]
x-opam-monorepo-opam-repositories: [
"file://$OPAM_MONOREPO_CWD/minimal-repo"
"file://$OPAM_MONOREPO_CWD/repo"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
opam-version: "2.0"
depends: [
"dune"
]
build: [ "dune" "build" ]
url {
src: "https://b.com/b.tbz"
checksum: [
"sha256=0000000000000000000000000000000000000000000000000000000000000000"
]
}
1 change: 1 addition & 0 deletions test/bin/missing-dev-repo.t/repo/repo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opam-version: "2.0"
25 changes: 25 additions & 0 deletions test/bin/missing-dev-repo.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
We have a simple project with a single package defined at the root.
It has a `x-opam-monorepo-opam-repositories` field set to use a local
opam-repository for locking

$ cat missing-dev-repo.opam
opam-version: "2.0"
depends: [
"dune"
"no-dev-repo"
]
x-opam-monorepo-opam-repositories: [
"file://$OPAM_MONOREPO_CWD/minimal-repo"
"file://$OPAM_MONOREPO_CWD/repo"
]

We provided a minimal opam-repository but locking should be successful.

$ gen-minimal-repo
$ opam-monorepo lock
==> Using 1 locally scanned package as the target.
==> Found 9 opam dependencies for the target package.
==> Querying opam database for their metadata and Dune compatibility.
==> Calculating exact pins for each of them.
opam-monorepo: [WARNING] Package no-dev-repo.1 has no dev-repo specified, but it needs a dev-repo to be successfully included in the duniverse.
==> Wrote lockfile with 0 entries to $TESTCASE_ROOT/missing-dev-repo.opam.locked. You can now run opam monorepo pull to fetch their sources.