From e92267f9ec59216042cabb02d500bd2d4627f146 Mon Sep 17 00:00:00 2001 From: Anil Madhavapeddy Date: Thu, 5 Jan 2017 17:58:16 +0000 Subject: [PATCH] [ci] expose more functions on `Target.v` These are convenience functions that match the equivalents for the unresolved `Target.t`, used in mirage-ci Signed-off-by: Anil Madhavapeddy --- ci/src/cI_target.ml | 8 ++++++++ ci/src/cI_target.mli | 2 ++ ci/src/datakit_ci.mli | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/ci/src/cI_target.ml b/ci/src/cI_target.ml index e41e6118c..cd1fa0664 100644 --- a/ci/src/cI_target.ml +++ b/ci/src/cI_target.ml @@ -87,6 +87,10 @@ let path = function type v = [ `PR of PR.t | `Ref of Ref.t ] +let pp_v f = function + | `PR pr -> Fmt.pf f "prs/%a" PR.pp pr + | `Ref x -> Fmt.pf f "refs/%a" Ref.pp x + let head = function | `PR x -> PR.commit x | `Ref x -> Ref.commit x @@ -96,3 +100,7 @@ let compare_v (x:v) (y:v) = Elt.compare (x :> Elt.t) (y :> Elt.t) let path_v = function | `PR pr -> path (`PR (PR.id pr)) | `Ref r -> path (`Ref (Ref.id r)) + +let repo_v = function + | `PR pr -> PR.repo pr + | `Ref r -> Ref.repo r diff --git a/ci/src/cI_target.mli b/ci/src/cI_target.mli index 0ce0ca9d2..c80622462 100644 --- a/ci/src/cI_target.mli +++ b/ci/src/cI_target.mli @@ -16,4 +16,6 @@ type v = [ `PR of PR.t | `Ref of Ref.t ] val head: v -> Commit.t val compare_v: v -> v -> int val path_v: v -> string +val repo_v : v -> Repo.t val unescape_ref: string -> Ref.name +val pp_v : v Fmt.t diff --git a/ci/src/datakit_ci.mli b/ci/src/datakit_ci.mli index e15583d12..21c5a71cb 100644 --- a/ci/src/datakit_ci.mli +++ b/ci/src/datakit_ci.mli @@ -142,6 +142,11 @@ module Target: sig val compare_v: v -> v -> int (** [compare_v] compares values of type {!v}. *) + val repo_v: v -> Repo.t + (** [repo_v v] is [v]'s repository. *) + + val pp_v: v Fmt.t + (** [pp_v] is the pretty-printer for resolved GitHub targets. *) end module Term: sig