Skip to content

Commit

Permalink
[ci] expose more functions on Target.v
Browse files Browse the repository at this point in the history
These are convenience functions that match the equivalents for
the unresolved `Target.t`, used in mirage-ci

Signed-off-by: Anil Madhavapeddy <anil@recoil.org>
  • Loading branch information
avsm committed Jan 5, 2017
1 parent b2d7211 commit 2539cd7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ci/src/cI_target.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "pr/%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
Expand All @@ -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
2 changes: 2 additions & 0 deletions ci/src/cI_target.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions ci/src/datakit_ci.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2539cd7

Please sign in to comment.