-
Notifications
You must be signed in to change notification settings - Fork 415
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
dune init --public: allow dashes etc #7111
Conversation
This seems to allow too much. I can't quite figure out what functions to use and what exactly is allowed in a |
Anything accepted by Lib_name.of_string should be allowed no? |
Hmm, I guess so. The failing existing test just made me doubt this solution. |
Could you add a DCO? |
Signed-off-by: Reynir Björnsson <reynir@reynir.dk>
Signed-off-by: Reynir Björnsson <reynir@reynir.dk>
I added a signed-off-by line. Let me know if I did it right. It's not cryptographically signed - my PGP key expired and I lost the password to the master key /o\ |
@reynir We don't need GPG signing only the Signed-off message in the commit. |
let* atom = atom_parser s in | ||
let* _ = | ||
match Lib_name.of_string_opt s with | ||
| None -> Error (err_msg ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably just want User_error.raise
here.
The tests are failing since it looks like names are not being validated correctly: $ dune init lib foo --public="some/invalid&name!"
- dune: option '--public': invalid component name `some/invalid&name!'
- Library names must be non-empty and composed only of the
- following
- characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
- Usage: dune init library [OPTION]… NAME [PATH]
- Try 'dune init library --help' or 'dune --help' for more information.
- [1]
+ Success: initialized library component named foo |
Thank you for your review @Alizter. Regarding the failing test I am aware. In the code base I wasn't able to find any function for validating public names (very possible I missed something) nor what is allowed in a public name. In other words, it's unclear to me if the failing test is actually invalid and if so how to check it. @rgrinberg suggests "[a]nything accepted by Lib_name.of_string should be allowed", and this is what it checks. Is this a bug with As for your comments about the code: the new code is basically the same as |
As for the failing test, I tried to run dune/tmp$ dune build
Entering directory '/home/reynir/workspace/dune'
File "tmp/dune", line 2, characters 14-32:
2 | (public_name some/invalid&name!)
^^^^^^^^^^^^^^^^^^
Error: The current scope doesn't define package "some/invalid&name!".
The only packages for which you can declare elements to be installed in this
directory are:
- chrome-trace (because of chrome-trace.opam)
- dune (because of dune.opam)
- dune-action-plugin (because of dune-action-plugin.opam)
- dune-build-info (because of dune-build-info.opam)
- dune-configurator (because of dune-configurator.opam)
- dune-glob (because of dune-glob.opam)
- dune-private-libs (because of dune-private-libs.opam)
- dune-rpc (because of dune-rpc.opam)
- dune-rpc-lwt (because of dune-rpc-lwt.opam)
- dune-site (because of dune-site.opam)
- dyn (because of dyn.opam)
- ocamlc-loc (because of ocamlc-loc.opam)
- ordering (because of ordering.opam)
- stdune (because of stdune.opam)
- xdg (because of xdg.opam) I then edited (package
(name some/invalid&name!)
(synopsis "test")
(depends
(ocaml (>= 4.08.0)))
(description "Just testing an invalid package name")) After this it seemed to successfully build. But if I cd'ed to the project root I got the following error when building (long time since I saw that error message!):
|
I think it is fine not to validate public_name as it is technically correct in the error message. We should however be validating the package stanza in dune-project files. |
@Alizter can you push this PR along? |
Co-authored-by: Ali Caglayan <alizter@gmail.com>
@rgrinberg I would like to expose a public name validation API in Lib_name, analogous to Lib_name and Lib_name.Local. There is a location in the code today but the validation is essentially left as a todo. I don't have time to look into that at the moment, but @reynir if you are interested you can the relevant code in Lib_name. |
@Alizter I don't really have the time, and the code base is large and unfamiliar to me. I also have no clue what is a valid public name and what is not. |
@reynir No worries, I'll continue this when I have some time. |
@emillon i think you've fixed this? |
Yes, this has been done in #8603. |
An attempt to fix #7108