Skip to content

Commit 16f442b

Browse files
committed
fix: correctly list vcs files in subdirectory
Signed-off-by: Rudi Grinberg <[email protected]>
1 parent 56a6a79 commit 16f442b

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/dune_vcs/vcs.ml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,27 @@ let files =
182182
in
183183
let f run args t =
184184
let open Fiber.O in
185-
let+ l = run t args in
186-
List.map l ~f:Path.Source.of_string
185+
let f =
186+
let prefix =
187+
Path.to_absolute_filename t.root |> Path.External.of_string |> Path.external_
188+
in
189+
let source_root =
190+
Path.to_absolute_filename (Path.source Path.Source.root)
191+
|> Path.External.of_string
192+
|> Path.external_
193+
in
194+
match Path.drop_prefix source_root ~prefix with
195+
| None -> fun p -> Some (Path.Source.of_string p)
196+
| Some prefix ->
197+
fun p ->
198+
(match
199+
let p = Path.Local.of_string p in
200+
Path.Local.descendant p ~of_:prefix
201+
with
202+
| None -> None
203+
| Some p -> Some (Path.Source.of_local p))
204+
in
205+
run t args >>| List.filter_map ~f
187206
in
188207
Staged.unstage
189208
@@ make_fun

test/blackbox-tests/test-cases/subst/git-subfolder.t

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,3 @@ Regression test for https://github.com/ocaml/dune/issues/11045
1414
$ git add -A && git commit --quiet --message "Initial commit"
1515
$ cd subfolder
1616
$ dune subst
17-
File ".", line 1, characters 0-0:
18-
Error: There is no dune-project file in the current directory, please add one
19-
with a (name <name>) field in it.
20-
Hint: 'dune subst' must be executed from the root of the project.
21-
[1]

0 commit comments

Comments
 (0)