summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-19 13:53:28 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-19 13:53:28 +0100
commit1ea2c761bdeaac89d3c00b30cd4780015b7db561 (patch)
tree626320a32b4b94123d173f18c23e7a38a2be633b
parent3b0ebb278320230256ebc2ae83e3696c1113bcba (diff)
downloadnimgit-1ea2c761bdeaac89d3c00b30cd4780015b7db561.tar.gz
nimgit-1ea2c761bdeaac89d3c00b30cd4780015b7db561.tar.bz2
nimgit-1ea2c761bdeaac89d3c00b30cd4780015b7db561.zip
update example: showLastCommit.nim
-rw-r--r--showLastCommit.nim21
1 files changed, 14 insertions, 7 deletions
diff --git a/showLastCommit.nim b/showLastCommit.nim
index 4e62960..2767111 100644
--- 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: