Ignore <package>.opam when <package> is empty

This commit is contained in:
Jérémie Dimino 2017-03-09 06:41:42 +00:00
parent 6ac0200d95
commit 74e015923a
3 changed files with 6 additions and 3 deletions

View File

@ -70,7 +70,7 @@ let find_root () =
if String_set.mem "jbuild-workspace" files then
cont counter ~candidates:((0, dir, to_cwd) :: candidates) dir ~to_cwd
else if String_set.exists files ~f:(fun fn ->
String.is_suffix fn ~suffix:".opam") then
String.is_suffix fn ~suffix:".opam" && fn <> ".opam") then
cont counter ~candidates:((1, dir, to_cwd) :: candidates) dir ~to_cwd
else if String_set.mem ".git" files || String_set.mem ".hg" files then
cont counter ~candidates:((2, dir, to_cwd) :: candidates) dir ~to_cwd

View File

@ -152,6 +152,9 @@ only declare parts of the packages in this subtree. Typically your
=<package>.opam= files should be at the root of your project, since
this is where =opam pin ...= will look for them.
Note that =<package>= must be non empty, so in particular =.opam=
files are ignored.
*** Package version
Note that Jbuilder will try to determine the version number of
@ -985,7 +988,7 @@ Jbuilder looks for the following entries in all these directories, in
order of precedences:
1. =jbuild-workspace=
2. any file ending with =.opam=
2. any file ending with =.opam=, except =.opam= itself
3. =.git= or =.hg=
The first entry to match in this list will determine the root. If this

View File

@ -148,7 +148,7 @@ let load () =
let path = File_tree.Dir.path dir in
String_set.fold (File_tree.Dir.files dir) ~init:acc ~f:(fun fn acc ->
match Filename.split_ext fn with
| Some (pkg, ".opam") ->
| Some (pkg, ".opam") when pkg <> "" ->
let version_from_opam_file =
let lines = lines_of_file (Path.relative path fn |> Path.to_string) in
List.find_map lines ~f:(fun s ->