Skip to content

Commit 8c750b1

Browse files
authored
Merge pull request #104 from dinosaure/fix-git-file-directory
Precisely check if an element is a file/directory with Git
2 parents 66dbe73 + be8a3d3 commit 8c750b1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plugins/yocaml_git/runtime.ml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,20 @@ struct
103103
let is_directory ~on path =
104104
match on with
105105
| `Source -> Source.lift @@ Source.is_directory ~on path
106-
| `Target -> Lwt.return true
106+
| `Target ->
107+
let open Lwt.Syntax in
108+
let+ k = Store.exists store (to_kv_path path) in
109+
Ok (k = Ok (Some `Dictionary))
110+
|> Result.fold ~ok:Fun.id ~error:(Fun.const false)
107111

108112
let is_file ~on path =
109113
match on with
110114
| `Source -> Source.lift @@ Source.is_file ~on path
111-
| `Target -> Lwt.return true
115+
| `Target ->
116+
let open Lwt.Syntax in
117+
let+ k = Store.exists store (to_kv_path path) in
118+
Ok (k = Ok (Some `Value))
119+
|> Result.fold ~ok:Fun.id ~error:(Fun.const false)
112120

113121
let exec ?is_success prog args =
114122
lift_result @@ Source.exec ?is_success prog args

0 commit comments

Comments
 (0)