Skip to content

Commit

Permalink
Merge pull request #650 from hannesm/variants
Browse files Browse the repository at this point in the history
use dune variants instead of functors
  • Loading branch information
dinosaure authored Feb 17, 2025
2 parents 0e2d16c + 5677c39 commit 1eebe0e
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 44 deletions.
18 changes: 8 additions & 10 deletions git-mirage.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ depends: [
"base64" {>= "3.5.0"}
"git" {= version}
"git-paf" {= version}
"awa" {>= "0.2.0"}
"awa-mirage" {>= "0.2.0"}
"dns" {>= "6.1.3"}
"dns-client" {>= "6.1.3"}
"awa" {>= "0.5.0"}
"awa-mirage" {>= "0.5.0"}
"tls" {>= "1.0.0"}
"tls-mirage" {>= "1.0.0"}
"uri"
"happy-eyeballs-mirage" {>= "0.1.2"}
"happy-eyeballs" {>= "0.1.2"}
"ca-certs-nss"
"mirage-crypto" {>= "1.0.0"}
"happy-eyeballs-mirage" {>= "2.0.0"}
"happy-eyeballs" {>= "2.0.0"}
"ca-certs-nss" {>= "3.108-1"}
"mirage-crypto" {>= "1.2.0"}
"ptime"
"x509" {>= "1.0.0"}
"cstruct"
Expand All @@ -33,9 +31,9 @@ depends: [
"fmt" {>= "0.8.9"}
"ipaddr" {>= "5.0.1"}
"lwt" {>= "5.3.0"}
"mirage-clock" {>= "3.1.0"}
"mirage-ptime" {>= "5.0.0"}
"mirage-flow" {>= "4.0.0"}
"mirage-time" {>= "2.0.1"}
"mirage-sleep" {>= "4.0.0"}
"rresult" {>= "0.7.0"}
"alcotest" {>= "1.2.3" & with-test}
"alcotest-lwt" {>= "1.2.3" & with-test}
Expand Down
2 changes: 0 additions & 2 deletions git-paf.opam
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ depends: [
"ipaddr"
"logs"
"lwt"
"mirage-clock"
"tcpip" {>= "7.0.0"}
"mirage-time"
"rresult" {>= "0.7.0"}
"tls" {>= "1.0.0"}
"uri"
Expand Down
6 changes: 1 addition & 5 deletions git-unix.opam
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ depends: [
"alcotest" {with-test & >= "1.1.0"}
"alcotest-lwt" {with-test & >= "1.1.0"}
"base64" {with-test & >= "3.0.0"}
"mirage-clock" {>= "4.1.0"}
"mirage-clock-unix" {>= "4.1.0"}
"astring" {>= "0.8.5"}
"mirage-time" {>= "2.0.0"}
"mirage-unix" {>= "5.0.0"}
"cmdliner" {>= "1.1.0"}
"decompress" {>= "1.4.0"}
"domain-name" {>= "0.3.0"}
Expand All @@ -40,7 +36,7 @@ depends: [
"cstruct" {>= "6.0.0"}
"mirage-flow" {>= "4.0.0"}
"ke" {>= "0.4" & with-test}
"mirage-crypto-rng" {>= "1.0.0" & with-test}
"mirage-crypto-rng" {>= "1.2.0" & with-test}
"mimic" {>= "0.0.8"}
"tls" {>= "1.0.0"}
]
Expand Down
2 changes: 1 addition & 1 deletion git.opam
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ depends: [
"encore" {>= "0.8"}
"alcotest" {with-test & >= "1.1.0"}
"alcotest-lwt" {with-test & >= "1.1.0"}
"mirage-crypto-rng" {with-test & >= "1.0.0"}
"mirage-crypto-rng" {with-test & >= "1.2.0"}
"cmdliner" {with-test & >= "1.1.0"}
"base-unix" {with-test}
"hxd" {>= "0.3.2"}
Expand Down
6 changes: 2 additions & 4 deletions src/git-mirage/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
fmt
tcpip
mirage-flow
mirage-time
mirage-clock
mirage-sleep
awa
awa-mirage))

Expand Down Expand Up @@ -44,5 +43,4 @@
domain-name
tcpip
mirage-flow
mirage-time
mirage-clock))
mirage-ptime))
17 changes: 10 additions & 7 deletions src/git-mirage/git_mirage_http.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ let git_mirage_http_headers = Mimic.make ~name:"git-mirage-http-headers"
let git_mirage_http_tls_config = Mimic.make ~name:"git-mirage-tls-config"

module Make
(Pclock : Mirage_clock.PCLOCK)
(TCP : Tcpip.Tcp.S)
(Happy_eyeballs : Mimic_happy_eyeballs.S with type flow = TCP.flow) : S =
struct
Expand Down Expand Up @@ -157,7 +156,10 @@ struct
match t.state with
| Handshake | Get _ ->
Lwt.return_error (`Msg "Handshake has not been done")
| Error `Git_paf e -> Lwt.return_error (`Msg (Fmt.str "Handshake got an error: git-paf: %a" Git_paf.pp_error e))
| Error (`Git_paf e) ->
Lwt.return_error
(`Msg
(Fmt.str "Handshake got an error: git-paf: %a" Git_paf.pp_error e))
| Post ({ output; _ } as v) ->
let output = output ^ Cstruct.to_string cs in
v.output <- output;
Expand All @@ -176,7 +178,10 @@ struct
let read t =
match t.state with
| Handshake -> Lwt.return_error (`Msg "Handshake has not been done")
| Error `Git_paf e -> Lwt.return_error (`Msg (Fmt.str "Handshake got an error: git-paf: %a" Git_paf.pp_error e))
| Error (`Git_paf e) ->
Lwt.return_error
(`Msg
(Fmt.str "Handshake got an error: git-paf: %a" Git_paf.pp_error e))
| Get { advertised_refs; uri; headers; ctx } ->
t.state <- Post { output = ""; uri; headers; ctx };
Lwt.return_ok (`Data (Cstruct.of_string advertised_refs))
Expand Down Expand Up @@ -260,14 +265,12 @@ struct
in
Lwt.return ctx

module NSS = Ca_certs_nss.Make (Pclock)

let with_optional_tls_config_and_headers ?headers ?authenticator ctx =
let time () = Some (Ptime.v (Pclock.now_d_ps ())) in
let time () = Some (Mirage_ptime.now ()) in
let authenticator =
match authenticator with
| None -> (
match NSS.authenticator () with
match Ca_certs_nss.authenticator () with
| Ok authenticator -> authenticator
| Error (`Msg err) ->
print_endline ("[git-mirage-http] NSS authenticator error: " ^ err);
Expand Down
1 change: 0 additions & 1 deletion src/git-mirage/git_mirage_http.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ module type S = sig
end

module Make
(Pclock : Mirage_clock.PCLOCK)
(TCP : Tcpip.Tcp.S)
(Happy_eyeballs : Mimic_happy_eyeballs.S with type flow = TCP.flow) : S
4 changes: 1 addition & 3 deletions src/git-mirage/git_mirage_ssh.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ module type S = sig
end

module Make
(Mclock : Mirage_clock.MCLOCK)
(TCP : Tcpip.Tcp.S)
(Time : Mirage_time.S)
(Happy_eyeballs : Mimic_happy_eyeballs.S with type flow = TCP.flow) : S =
struct
module SSH = struct
include Awa_mirage.Make (TCP) (Time) (Mclock)
include Awa_mirage.Make (TCP)

type nonrec endpoint = Happy_eyeballs.t * endpoint

Expand Down
2 changes: 0 additions & 2 deletions src/git-mirage/git_mirage_ssh.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@ module type S = sig
end

module Make
(Mclock : Mirage_clock.MCLOCK)
(TCP : Tcpip.Tcp.S)
(Time : Mirage_time.S)
(Happy_eyeballs : Mimic_happy_eyeballs.S with type flow = TCP.flow) : S
2 changes: 0 additions & 2 deletions src/git-paf/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
(libraries
logs
uri
mirage-time
mirage-clock
tcpip
mirage-flow
domain-name
Expand Down
4 changes: 0 additions & 4 deletions src/git-unix/dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
git-mirage.tcp
git-mirage.ssh
git-mirage.http
mirage-clock-unix
mirage-unix
mirage-time
happy-eyeballs-lwt
mirage-clock
decompress.de
tls
bos
Expand Down
4 changes: 2 additions & 2 deletions src/git-unix/git_unix_mimic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ end
let fifo_endpoint, _ = Mimic.register ~name:"fifo" (module FIFO)

module A = Git_mirage_tcp.Make (TCP) (Happy_eyeballs)
module B = Git_mirage_ssh.Make (Mclock) (TCP) (Unix_os.Time) (Happy_eyeballs)
module C = Git_mirage_http.Make (Pclock) (TCP) (Happy_eyeballs)
module B = Git_mirage_ssh.Make (TCP) (Happy_eyeballs)
module C = Git_mirage_http.Make (TCP) (Happy_eyeballs)

let ctx happy_eyeballs =
let ctx =
Expand Down
2 changes: 1 addition & 1 deletion test/smart/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ let reporter ppf =
in
{ Logs.report }

let () = Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna)
let () = Mirage_crypto_rng_unix.use_default ()
let () = Fmt_tty.setup_std_outputs ~style_renderer:`Ansi_tty ~utf_8:true ()
let () = Logs.set_reporter (reporter Fmt.stderr)
let () = Logs.set_level ~all:true (Some Logs.Debug)
Expand Down

0 comments on commit 1eebe0e

Please sign in to comment.