Skip to content

Commit

Permalink
fix(pkg): Only parse blob objects into files (ocaml#9352)
Browse files Browse the repository at this point in the history
Fixes ocaml#9328

Signed-off-by: Marek Kubica <[email protected]>
  • Loading branch information
Leonidas-from-XIV authored Dec 7, 2023
1 parent 75f5388 commit 2eb12b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/dune_pkg/rev_store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ module File = struct
let perm = Re.(rep1 digit) in
let hash = Re.(rep1 alnum) in
let type_ = Re.(rep1 alpha) in
let size = Re.(rep1 digit) in
let size = Re.(alt [ rep1 digit; str "-" ]) in
let path = Re.(rep1 any) in
[ perm
; space
; type_
; Re.group type_
; space
; Re.group hash
; space
Expand All @@ -227,11 +227,16 @@ module File = struct
|> Re.compile
in
fun line ->
let m = Re.exec re line in
{ hash = Re.Group.get m 1
; size = Int.of_string_exn @@ Re.Group.get m 2
; path = Path.Local.of_string @@ Re.Group.get m 3
}
Re.exec_opt re line
|> Option.bind ~f:(fun m ->
match Re.Group.get m 1 with
| "blob" ->
Some
{ hash = Re.Group.get m 2
; size = Int.of_string_exn @@ Re.Group.get m 3
; path = Path.Local.of_string @@ Re.Group.get m 4
}
| _ -> None)
;;

let path t = t.path
Expand Down Expand Up @@ -293,7 +298,8 @@ module Remote = struct

let files_at_rev repo (Rev rev) =
run_capture_zero_separated_lines repo [ "ls-tree"; "-z"; "--long"; "-r"; rev ]
>>| File.Set.of_list_map ~f:File.parse
>>| List.filter_map ~f:File.parse
>>| File.Set.of_list
;;

let rev_of_name { repo; handle; default_branch = _ } ~name =
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/pkg/git-repo.t
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ With this set up in place, locking should still work as the commit is not
relevant

$ XDG_CACHE_HOME=$PWD/dune-cache dune pkg lock 2> /dev/null && echo "Solution found"
[1]
Solution found

0 comments on commit 2eb12b9

Please sign in to comment.