summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-17 02:25:42 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-17 02:25:42 +0100
commit998d8ef5a4bf37fbdcfef9b55f8d279df6e62855 (patch)
treebd90e35f9cc531c7b530db5996f3c13ce21e1019
parentb2fc1ab137ddf5da457942d018ce002037bd7b39 (diff)
downloadnimgit-998d8ef5a4bf37fbdcfef9b55f8d279df6e62855.tar.gz
nimgit-998d8ef5a4bf37fbdcfef9b55f8d279df6e62855.tar.bz2
nimgit-998d8ef5a4bf37fbdcfef9b55f8d279df6e62855.zip
commit.nim: new procs: $, getParrentCount, getParrentId, getTree
-rw-r--r--nimgit/commit.nim14
1 files changed, 13 insertions, 1 deletions
diff --git a/nimgit/commit.nim b/nimgit/commit.nim
index 517cd0f..2be6a8f 100644
--- a/nimgit/commit.nim
+++ b/nimgit/commit.nim
@@ -11,6 +11,7 @@ proc lookupCommit* (repo: GitRepository, oid: GitObjectId): GitCommit =
proc getObjectId* (commit: GitCommit): GitObjectId = git_commit_id(commit)
+proc `$`* (commit: GitCommit): string = $commit.getObjectId()
proc getSummary* (commit: GitCommit): string = $git_commit_summary(commit)
@@ -26,7 +27,6 @@ proc getAuthor* (commit: GitCommit): GitSignature =
result.email = $author.email
result.when = parseGitTime(author.when)
-
proc getCommitter* (commit: GitCommit): GitSignature =
let author = git_commit_committer(commit)
@@ -35,9 +35,21 @@ proc getCommitter* (commit: GitCommit): GitSignature =
result.when = parseGitTime(author.when)
+proc getParrentCount* (commit: GitCommit): int = cast[int](git_commit_parentcount(commit))
+
+proc getParrentId* (commit: GitCommit): GitObjectId = git_commit_parent_id(commit, 0)
+
proc getParrent* (commit: GitCommit): GitCommit =
let error = git_commit_parent(addr result, commit, 0)
if error != 0:
free(result)
raise newException(CatchableError, "parrent lookup failed: " & $error.getResultCode)
+
+
+proc getTree* (commit: GitCommit): GitTree =
+ let error = git_commit_tree(addr result, commit)
+
+ if error != 0:
+ free(result)
+ raise newException(CatchableError, "tree lookup failed: " & $error.getResultCode)