ctucx.git: nimgit

[nimlang] nim-wrapper for libgit2

commit e0ba5b236384f0c3463433effa5b779379ecb358
parent 0219741ae61a0a3b3ed80d7fe562f5dfc1869cb4
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 16 Mar 2021 13:49:23 +0100

commit.nim: add getCommitter and getParrent
1 file changed, 13 insertions(+), 0 deletions(-)
M
nimgit/commit.nim
|
13
+++++++++++++
diff --git a/nimgit/commit.nim b/nimgit/commit.nim
@@ -24,3 +24,16 @@ proc getAuthor* (commit: GitCommit): GitSignature =
     result.name  = $author.name
     result.email = $author.email
     result.when  = parseGitTime(author.when)
+
+proc getCommitter* (commit: GitCommit): GitSignature =
+    let author = git_commit_committer(commit)
+
+    result.name  = $author.name
+    result.email = $author.email
+    result.when  = parseGitTime(author.when)
+
+proc getParrent* (commit: GitCommit): GitCommit =
+    let error = git_commit_parent(addr result, commit, 0)
+
+    if error != 0:
+        raise newException(CatchableError, "parrent lookup failed: " & $error.getResultCode)