dune-release
dune-release copied to clipboard
dune-release picks wrong DIST_NAME
Hi,
I use dune-release for ocaml-decoders. It's great!
Recently I started using (generate_opam_files true).
dune-release with no args now picks decoders-yojson as the distribution name, even though I have (name decoders) in the dune-project, and the longest prefix of *.opam is decoders.
dune-release --name decoders works great (although the description of the generated PR to the opam repository seems still to use the info for decoders-yojson instead of decoders - see "Yojson backend for decoders" in https://github.com/ocaml/opam-repository/pull/17523).
Forgot to mention - I got this behaviour both on v1.4.0 and master (7367f1df).
Same issue here:
$ dune-release -p repr,ppx_repr
[-] Building source archive
[+] Wrote archive _build/repr-fuzz-0.2.0.tbz
I would expect the archive name to be repr-0.2.0.tbz (as it is specified in the dune file)
Same problem here. I think this is related to the function Pkg.dune_project_name, see that snippet:
Bos.OS.File.read_lines file >>| fun lines ->
List.fold_left
(fun acc line ->
(* sorry *)
match String.cut ~sep:"(name " (String.trim line) with
| Some (_, s) ->
Some
(String.trim
~drop:(function ')' | ' ' -> true | _ -> false)
s)
| _ -> acc)
None lines
which shows that the function keeps the last name it found (because fold_left processes from beginning to end of the list). Problem is usually the name of the project is at the beginning of the file, then come the package stanzas, which also have a (name ...) field. In my case, changing the order of the packages to set the one with the intended project name last fixes the problem.
Anyway, this parsing of the dune-project file seems a bit brittle to me. Maybe some code from dune could be called instead?
Dune does not offer proper parsing utilities unfortunately but using a porper sexp parser should fix this and we're planning on incorporating one for 2.0.0.
This bug won't show up anymore though as we'll use the name of the github repo for the tarball instead of the package or project name defined in dune-project and that's the only place where we use the project name.