summaryrefslogtreecommitdiff
path: root/lib/git_unhelpers.ml
blob: 28d4d3a830b1218d6d8e417b8c593280ffd94499 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(* These will be reimplemented using OCaml's Git library, one day... *)

let get_git_log repo_path =
  let full_path = Filename.concat Config.git_directory repo_path in
  let full_cmd =
    let cmd = Printf.sprintf "git -C %s log" full_path in
    let options = [ "--pretty=format:'%ad %s'"; "--date=short"; "-n 10" ] in
    String.concat " " (cmd :: options)
  in
  let ic = Unix.open_process_in full_cmd in
  let rec read_lines acc =
    try
      let line = input_line ic in
      read_lines (line :: acc)
    with End_of_file ->
      ignore (Unix.close_process_in ic);
      List.rev acc
  in
  read_lines []
Copyright 2019--2025 Marius PETER