ctucx.git: nimgit

[nimlang] nim-wrapper for libgit2

commit db4fea498da41c9ffb799eb960acabe701717188
parent 8794e7fd1122448a76317eba2a6a67675788554d
Author: Leah (ctucx) <leah@ctu.cx>
Date: Thu, 18 Mar 2021 00:24:49 +0100

tag.nim: ad procs lookupTag, type, owner, id, shortId, name, message, tagger, target, targetId, peeltarget, targetType
1 file changed, 42 insertions(+), 0 deletions(-)
A
nimgit/tag.nim
|
42
++++++++++++++++++++++++++++++++++++++++++
diff --git a/nimgit/tag.nim b/nimgit/tag.nim
@@ -0,0 +1,42 @@
+import nimgit2
+import types, free, utils, objects
+
+proc lookupTag* (repo: GitRepository, id: GitObjectId): GitTag =
+    let error = git_tag_lookup(addr result, repo, id)
+
+    if error != 0:
+        free(result)
+        raise newException(CatchableError, "Tag lookup failed: " & $error.getResultCode)
+
+proc type* (obj: GitTag): GitObjectKind = cast[GitObject](obj).type
+
+proc owner* (tag: GitTag): GitRepository = git_tag_owner(tag)
+
+proc id* (tag: GitTag): GitObjectId = git_tag_id(tag)
+
+proc shortId* (tag: GitTag): string = cast[GitObject](tag).shortId()
+
+proc name* (tag: GitTag): string = $git_tag_name(tag)
+
+proc message* (tag: GitTag): string = $git_tag_message(tag)
+
+proc tagger* (tag: GitTag): GitSignature = git_tag_tagger(tag).parseGitSignature
+
+
+proc target* (tag: GitTag): GitObject =
+    let error = git_tag_target(addr result, tag)
+
+    if error != 0:
+        free(result)
+        raise newException(CatchableError, "Cannot get target object: " & $error.getResultCode)
+
+proc targetId* (tag: GitTag): GitObjectId = git_tag_target_id(tag)
+
+proc peelTarget* (tag: GitTag): GitObject =
+    let error = git_tag_peel(addr result, tag)
+
+    if error != 0:
+        free(result)
+        raise newException(CatchableError, "Tag peel failed: " & $error.getResultCode)
+
+proc targetType* (tag: GitTag): GitObjectKind = cast[GitObjectKind](git_tag_target_type(tag))