package drom_lib

  1. Overview
  2. Docs

Source file git.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(**************************************************************************)
(*                                                                        *)
(*    Copyright 2020 OCamlPro & Origin Labs                               *)
(*                                                                        *)
(*  All rights reserved. This file is distributed under the terms of the  *)
(*  GNU Lesser General Public License version 2.1, with the special       *)
(*  exception on linking described in the file LICENSE.                   *)
(*                                                                        *)
(**************************************************************************)

let user () =
  match Misc.call_get_fst_line "git config --get user.name" with
  | Some user -> user
  | None -> raise Not_found

let email () =
  match Misc.call_get_fst_line "git config --get user.email" with
  | Some email -> email
  | None -> raise Not_found

let call args = Misc.call (Array.of_list ("git" :: args))

let run args = try call args with _ -> ()

let update_submodules () =
  if Sys.file_exists ".gitmodules" then
    run [ "submodule"; "update"; "--init"; "--recursive" ]

let remove dir =
  Misc.call [| "rm"; "-rf"; dir |];
  run [ "rm"; "-rf"; dir ]

let rename old_dir new_dir =
  Misc.call [| "mv"; old_dir; new_dir |];
  run [ "rm"; "-rf"; old_dir ];
  run [ "add"; new_dir ]
OCaml

Innovation. Community. Security.