forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: check package names are valid opam names (ocaml#8331)
This adds a `Package_name.Opam_compatible` variant that uses opam conventions. The corresponding parser is used if lang dune >= 3.11. Signed-off-by: Etienne Millon <me@emillon.org>
- Loading branch information
Showing
5 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Ensure that package names in `dune-project` are valid opam package | ||
names. (#8331, @emillon) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Version check: | ||
|
||
$ cat > dune-project << EOF | ||
> (lang dune 3.10) | ||
> (package | ||
> (name some&name) | ||
> (allow_empty)) | ||
> EOF | ||
$ dune build | ||
|
||
Validation: | ||
|
||
$ test() { | ||
> cat > dune-project << EOF | ||
> (lang dune 3.11) | ||
> (package | ||
> (name $1) | ||
> (allow_empty)) | ||
> EOF | ||
> dune build | ||
> } | ||
|
||
$ test 'some&name' | ||
File "dune-project", line 3, characters 7-16: | ||
3 | (name some&name) | ||
^^^^^^^^^ | ||
Error: "some&name" is an invalid opam package name. | ||
Package names can contain letters, numbers, '-', '_' and '+', and need to | ||
contain at least a letter. | ||
Hint: some_name would be a correct opam package name | ||
[1] | ||
|
||
Leading invalid characters are removed: | ||
|
||
$ test '0test' | ||
|
||
When all characters are removed, a valid name is suggested: | ||
|
||
$ test '0' | ||
File "dune-project", line 3, characters 7-8: | ||
3 | (name 0) | ||
^ | ||
Error: "0" is an invalid opam package name. | ||
Package names can contain letters, numbers, '-', '_' and '+', and need to | ||
contain at least a letter. | ||
Hint: p0 would be a correct opam package name | ||
[1] | ||
|
||
A package name can start with a number: | ||
|
||
$ test 0install | ||
|
||
But it needs at least a letter: | ||
|
||
$ test 0-9 | ||
File "dune-project", line 3, characters 7-10: | ||
3 | (name 0-9) | ||
^^^ | ||
Error: "0-9" is an invalid opam package name. | ||
Package names can contain letters, numbers, '-', '_' and '+', and need to | ||
contain at least a letter. | ||
Hint: p0-9 would be a correct opam package name | ||
[1] |