Skip to content

Commit

Permalink
_
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Sep 29, 2020
1 parent 3b60311 commit 7d690bd
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/dune_engine/package.ml
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,18 @@ module Source_kind = struct
| Bitbucket
| Gitlab

let kind_string_map =
[ (Github, "github"); (Bitbucket, "bitbucket"); (Gitlab, "gitlab") ]
let to_string = function
| Github -> "github"
| Bitbucket -> "bitbucket"
| Gitlab -> "gitlab"

type t =
{ user : string
; repo : string
; kind : kind
}

let dyn_of_kind kind =
List.assoc kind_string_map kind |> Option.value_exn |> Dyn.Encoder.string
let dyn_of_kind kind = kind |> to_string |> Dyn.Encoder.string

let to_dyn { user; repo; kind } =
let open Dyn.Encoder in
Expand All @@ -256,9 +257,6 @@ module Source_kind = struct
| Bitbucket -> "bitbucket.org"
| Gitlab -> "gitlab.com"

let to_string { user; repo; kind } =
sprintf "git+https://%s/%s/%s.git" (host_of_kind kind) user repo

let homepage { kind; user; repo } =
let host = host_of_kind kind in
sprintf "https://%s/%s/%s" host user repo
Expand Down Expand Up @@ -292,8 +290,11 @@ module Source_kind = struct
| Some v -> Dune_lang.Syntax.since Stanza.syntax v )
>>> plain_string of_string
in
let constr = List.assoc kind_string_map kind |> Option.value_exn in
let constr = to_string kind in
(constr, decode))

let to_string { user; repo; kind } =
sprintf "git+https://%s/%s/%s.git" (host_of_kind kind) user repo
end

type t =
Expand Down

0 comments on commit 7d690bd

Please sign in to comment.