From dea930f478d75ee714d2cbc2603144a50be3aba4 Mon Sep 17 00:00:00 2001 From: xvw Date: Tue, 4 Nov 2025 18:02:33 +0100 Subject: [PATCH] Remove Polymorphic comparison in Yocaml_git --- CHANGES.md | 4 ++++ plugins/yocaml_git/runtime.ml | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fcab03f..a7f7e38 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ ### Unreleased +#### Yocaml_git + +- A more robust metric for `is_file` and `is_directory` in Git context (by [dinosaure](https://github.com/dinosaure)) + #### Yocaml_liquid - ⁠First release - Add support for Shopify Liquid templating language (by [Dev-JoyA](https://github.com/Dev-JoyA)) diff --git a/plugins/yocaml_git/runtime.ml b/plugins/yocaml_git/runtime.ml index 368b2d2..509a576 100644 --- a/plugins/yocaml_git/runtime.ml +++ b/plugins/yocaml_git/runtime.ml @@ -104,19 +104,21 @@ struct match on with | `Source -> Source.lift @@ Source.is_directory ~on path | `Target -> - let open Lwt.Syntax in - let+ k = Store.exists store (to_kv_path path) in - Ok (k = Ok (Some `Dictionary)) - |> Result.fold ~ok:Fun.id ~error:(Fun.const false) + let open Lwt.Infix in + Store.exists store (to_kv_path path) + >|= Result.fold + ~ok:(function Some `Dictionary -> true | _ -> false) + ~error:(Fun.const false) let is_file ~on path = match on with | `Source -> Source.lift @@ Source.is_file ~on path | `Target -> - let open Lwt.Syntax in - let+ k = Store.exists store (to_kv_path path) in - Ok (k = Ok (Some `Value)) - |> Result.fold ~ok:Fun.id ~error:(Fun.const false) + let open Lwt.Infix in + Store.exists store (to_kv_path path) + >|= Result.fold + ~ok:(function Some `Value -> true | _ -> false) + ~error:(Fun.const false) let exec ?is_success prog args = lift_result @@ Source.exec ?is_success prog args