diff options
author | Marius Peter <marius.peter@tutanota.com> | 2025-03-01 19:19:30 +0100 |
---|---|---|
committer | Marius Peter <marius.peter@tutanota.com> | 2025-03-01 19:19:30 +0100 |
commit | 4946275b48bfc92ce4b420e36c6cf48694776bbc (patch) | |
tree | 0dad20f647c17f90d5ba583539a8a2f02d11e5ce /lib/git_unhelpers.ml | |
parent | e92e763e06d58a03224189d53044c4f5e1f907f0 (diff) |
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.
Diffstat (limited to 'lib/git_unhelpers.ml')
-rw-r--r-- | lib/git_unhelpers.ml | 19 |
1 files changed, 19 insertions, 0 deletions
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 [] |