Skip to content

Commit

Permalink
Allow ocaml.org to run while offline (#1366)
Browse files Browse the repository at this point in the history
When offline, ocaml.org uses the current local state of opam-repository. This enables working on the codebase even when there is no Internet access.
  • Loading branch information
AshineFoster authored Aug 1, 2023
1 parent 78863d4 commit 2302b35
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/ocamlorg_package/lib/opam_repository.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ module Process = struct

let exec cmd =
let proc = Lwt_process.open_process_none cmd in
proc#status >|= check_status cmd
let open Lwt.Syntax in
let+ status = proc#status in
match status with Unix.WEXITED 0 -> Ok () | s -> Error (cmd, s)

let pread cmd =
let proc = Lwt_process.open_process_in cmd in
Expand Down Expand Up @@ -51,7 +53,7 @@ let last_commit () =

let clone () =
let open Lwt.Syntax in
let* () =
let* res =
Process.exec
( "git",
[|
Expand All @@ -61,13 +63,24 @@ let clone () =
Fpath.to_string clone_path;
|] )
in
(match res with Ok () -> () | Error (c, s) -> Process.check_status c s);
last_commit ()

let pull () =
let open Lwt.Syntax in
let* () =
let* pul =
Process.exec (git_cmd [ "pull"; "-q"; "--ff-only"; "origin"; "master" ])
in
(match pul with
| Ok () -> ()
| Error (_, Unix.WEXITED 1) ->
prerr_endline
"\n\
Pulling from opam repository was not possible. \n\
We will continue by building the package state\n\
using the existing local state of opam-repository.\n\
Some functionality might not work properly.\n"
| Error (c, s) -> Process.check_status c s);
last_commit ()

let fold_dir f acc directory =
Expand Down

0 comments on commit 2302b35

Please sign in to comment.