From 208f91b52fff5f7b6120b19b80e529821d70d009 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 16 Jan 2023 20:41:29 +0100 Subject: [PATCH] feat(git): some debugging tools for git --- lua/lazy/manage/git.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/lazy/manage/git.lua b/lua/lazy/manage/git.lua index 76f7009..5d431ae 100644 --- a/lua/lazy/manage/git.lua +++ b/lua/lazy/manage/git.lua @@ -225,4 +225,14 @@ function M.get_config(repo) return ret end +function M.count(repo, commit1, commit2) + local lines = Process.exec({ "git", "rev-list", "--count", commit1 .. ".." .. commit2 }, { cwd = repo }) + return tonumber(lines[1] or "0") or 0 +end + +function M.age(repo, commit) + local lines = Process.exec({ "git", "show", "-s", "--format=%cr", "--date=short", commit }, { cwd = repo }) + return lines[1] or "" +end + return M