ctucx.git: nimgit

[nimlang] nim-wrapper for libgit2

commit 1ea2c761bdeaac89d3c00b30cd4780015b7db561
parent 3b0ebb278320230256ebc2ae83e3696c1113bcba
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 19 Mar 2021 13:53:28 +0100

update example: showLastCommit.nim
1 file changed, 14 insertions(+), 7 deletions(-)
M
showLastCommit.nim
|
21
++++++++++++++-------
diff --git a/showLastCommit.nim b/showLastCommit.nim
@@ -1,4 +1,4 @@
-import os, times, posix, strutils
+import os, times
 import nimgit
 
 if paramCount() == 0:

@@ -10,6 +10,7 @@ discard git_libgit2_init()
 try:
     let
       gitRepository = openGitRepository(paramStr(1))
+      config        = gitRepository.config
       objId         = gitRepository.lookupObjectIdByName("HEAD")
       commit        = gitRepository.lookupCommit(objId)
       author        = commit.author

@@ -20,6 +21,7 @@ try:
 
     echo "Last commit on HEAD in repo: " & $gitRepository
     echo "==================="
+    echo "config value of core.bare: " & $config.getBool("core.bare")
     echo "hash: " & $objId & " (" & commit.shortId & ")"
     echo "committer: " & committer.name & " <" & committer.email & ">"
     echo "author: " & author.name & " <" & author.email & ">"

@@ -38,15 +40,20 @@ try:
 
     echo "tree of that commit:"
     echo "======================"
-    for entry in tree:
-      if entry.type == goTree:
-        for entry in tree:
-          echo $entry.id & " " & entry.modeStr & " " & $entry.type & " " & entry.name
-      else:
-        echo $entry.id & " " & entry.modeStr & " " & $entry.type & " " & entry.name
+    for element in tree.walk:
+      let (path, entry) = element
+
+      echo $entry.id & " " & entry.modeStr & " " & $entry.type & " " & path & entry.name
+
+      free(entry)
+
+    echo tree.entries
+
+    echo ""
 
     free(tree)
     free(commit)
+    free(config)
     free(gitRepository)
 
 except: