ctucx.git: nimgit

[nimlang] nim-wrapper for libgit2

commit c22c4349210773c5efc8a076b2e123d00f233c48
parent b84069a736b112dc50f1a371d890e9c1003f1ac7
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 17 Mar 2021 18:28:18 +0100

update implemented.txt and examples
3 files changed, 34 insertions(+), 18 deletions(-)
M
implemented.txt
|
8
++++++++
M
listAllCommits.nim
|
28
++++++++++++++++------------
M
showLastCommit.nim
|
16
++++++++++------
diff --git a/implemented.txt b/implemented.txt
@@ -10,9 +10,17 @@ branch.nim             branches                       git_branch_iterator_new
 branch.nim             branches                       git_branch_next
 
 commit.nim             lookupCommit                   git_commit_lookup
+commit.nim             owner                          git_commit_owner
+commit.nim             repo (alias)                   git_commit_owner
+commit.nim             rawHeader                      git_commit_raw_header
 commit.nim             summary                        git_commit_summary
 commit.nim             body                           git_commit_body
 commit.nim             message                        git_commit_message
+commit.nim             messageEncoding                git_commit_message_encoding
+commit.nim             rawMessage                     git_commit_message_raw
+commit.nim             gpgSignature                   git_commit_extract_signature
+commit.nim             time                           git_commit_time
+commit.nim             time                           git_commit_time_offset
 commit.nim             objectId                       git_commit_id
 commit.nim             author                         git_commit_author
 commit.nim             committer                      git_commit_committer
diff --git a/listAllCommits.nim b/listAllCommits.nim
@@ -18,27 +18,31 @@ try:
 
     for gitOid in gitRevisionWalker:
         let
-          gitCommit    = gitRepository.lookupCommit(gitOid)
-          author       = gitCommit.author
-          committer    = gitCommit.committer
-          parentCount  = gitCommit.parentCount
+          commit       = gitRepository.lookupCommit(gitOid)
+          author       = commit.author
+          committer    = commit.committer
+          parentCount  = commit.parentCount
+          signature    = commit.gpgSignature
 
         echo "==================="
         echo "hash: " & $gitOid
         echo "committer: " & committer.name & " <" & committer.email & ">"
         echo "author: " & author.name & " <" & author.email & ">"
-        echo "when: " & $author.when.time
-        echo "message: " & gitCommit.summary
+        echo "when: " & $commit.time
+        echo "message: " & commit.summary
+        echo "tree id: " & $commit.treeId
         echo "parentCount: " & $parentCount
 
-        var id = 0
-        if parentCount > 0:
-            while id < parentCount:
-                echo "parent: " & $gitCommit.parentId(id)
-                inc(id)
+        for parentId in commit.parentIds:
+            echo "parent: " & $parentId
+
+        if signature[0] != "":
+            echo "signature: " & $signature
+
         echo ""
 
-        free(gitCommit)
+
+        free(commit)
 
     free(gitRepository)
 
diff --git a/showLastCommit.nim b/showLastCommit.nim
@@ -15,23 +15,27 @@ try:
       author        = commit.author
       committer     = commit.committer
       parentCount   = commit.parentCount
+      signature     = commit.gpgSignature
 
     echo "Last commit on HEAD in repo: " & $gitRepository
     echo "==================="
     echo "hash: " & $objId
     echo "committer: " & committer.name & " <" & committer.email & ">"
     echo "author: " & author.name & " <" & author.email & ">"
-    echo "when: " & $author.when.time
+    echo "when: " & $commit.time
     echo "message: " & commit.summary
+    echo "tree id: " & $commit.treeId
     echo "parentCount: " & $parentCount
 
-    var id = 0
-    if parentCount > 0:
-        while id < parentCount:
-            echo "parent: " & $commit.parentId(id)
-            inc(id)
+    for parentId in commit.parentIds:
+        echo "parent: " & $parentId
+
+    if signature[0] != "":
+        echo "signature: " & $signature
+
     echo ""
 
+
     free(commit)
     free(gitRepository)