From 4946275b48bfc92ce4b420e36c6cf48694776bbc Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Sat, 1 Mar 2025 19:19:30 +0100 Subject: Start work on Git "un"helper functions. Worse is better. I'll revisit the OCaml Git package once I'm more comfortable with OCaml overall. --- lib/git_unhelpers.ml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/git_unhelpers.ml (limited to 'lib/git_unhelpers.ml') diff --git a/lib/git_unhelpers.ml b/lib/git_unhelpers.ml new file mode 100644 index 0000000..28d4d3a --- /dev/null +++ b/lib/git_unhelpers.ml @@ -0,0 +1,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 [] -- cgit v1.2.3