feat(git): some debugging tools for git

This commit is contained in:
Folke Lemaitre 2023-01-16 20:41:29 +01:00
parent 0cbd91d2cd
commit 208f91b52f
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 10 additions and 0 deletions

View File

@ -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