ctucx.git: nimgit

[nimlang] nim-wrapper for libgit2

commit b8cb5804a1c271f1e3615649ca699c5b4d2367ac
parent e389a36cbcfc305f19a45fd7e51ace0bc43d2a77
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 17 Mar 2021 11:34:59 +0100

commit.nim: rename procs, new proc treeId
1 file changed, 15 insertions(+), 12 deletions(-)
M
nimgit/commit.nim
|
27
+++++++++++++++------------
diff --git a/nimgit/commit.nim b/nimgit/commit.nim
@@ -9,25 +9,25 @@ proc lookupCommit* (repo: GitRepository, oid: GitObjectId): GitCommit =
         raise newException(CatchableError, "Commit lookup failed: " & $error.getResultCode)
 
 
-proc getObjectId* (commit: GitCommit): GitObjectId = git_commit_id(commit)
+proc objectId* (commit: GitCommit): GitObjectId = git_commit_id(commit)
 
-proc `$`* (commit: GitCommit): string = $commit.getObjectId()
+proc `$`* (commit: GitCommit): string = $commit.objectId()
 
-proc getSummary* (commit: GitCommit): string = $git_commit_summary(commit)
+proc summary* (commit: GitCommit): string = $git_commit_summary(commit)
 
-proc getMessage* (commit: GitCommit): string = $git_commit_message(commit)
+proc body* (commit: GitCommit): string = $git_commit_body(commit)
 
-proc getShortMessage* (commit: GitCommit): string = commit.getSummary()
+proc message* (commit: GitCommit): string = $git_commit_message(commit)
 
 
-proc getAuthor* (commit: GitCommit): GitSignature =
+proc author* (commit: GitCommit): GitSignature =
     let author = git_commit_author(commit)
 
     result.name  = $author.name
     result.email = $author.email
     result.when  = parseGitTime(author.when)
 
-proc getCommitter* (commit: GitCommit): GitSignature =
+proc committer* (commit: GitCommit): GitSignature =
     let author = git_commit_committer(commit)
 
     result.name  = $author.name

@@ -35,19 +35,22 @@ proc getCommitter* (commit: GitCommit): GitSignature =
     result.when  = parseGitTime(author.when)
 
 
-proc getParrentCount* (commit: GitCommit): int = cast[int](git_commit_parentcount(commit))
+proc hasParents* (commit: GitCommit): bool = cast[bool](git_commit_parentcount(commit))
 
-proc getParrentId* (commit: GitCommit): GitObjectId = git_commit_parent_id(commit, 0)
+proc parentCount* (commit: GitCommit): int = cast[int](git_commit_parentcount(commit))
 
-proc getParrent* (commit: GitCommit): GitCommit =
-    let error = git_commit_parent(addr result, commit, 0)
+proc parentId* (commit: GitCommit, id: int = 0): GitObjectId = git_commit_parent_id(commit, cuint(id))
+
+proc parent* (commit: GitCommit, id: int = 0): GitCommit =
+    let error = git_commit_parent(addr result, commit, cuint(id))
 
     if error != 0:
         free(result)
         raise newException(CatchableError, "parrent lookup failed: " & $error.getResultCode)
 
+proc treeId* (commit: GitCommit): GitObjectId = git_commit_tree_id(commit)
 
-proc getTree* (commit: GitCommit): GitTree =
+proc tree* (commit: GitCommit): GitTree =
     let error = git_commit_tree(addr result, commit)
 
     if error != 0: