Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] expose more functions on Target.v #430

Merged
merged 1 commit into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "prs/%a" PR.pp pr
| `Ref x -> Fmt.pf f "refs/%a" Ref.pp x
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems strange that one case is plural and the other isn't.

Looks like we use pr and ref in URLs, but prs/heads/tags when parsing. Git uses .git/refs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes not sure where this is used. I've tried to not use s in the datakit/github bridge, but indeed Git is putting s everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only using this pp_v function for branch name calculation, so the values don't seem significant (but should be consistent). I'll modify it to be plural to match Git then.


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