summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-17 16:34:24 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-17 16:34:24 +0100
commit910bc779ad1f2fe7fcfbdc6d3b5c871e6084140d (patch)
tree6077fde2fc26a9f328e0d5c7d657bf638f8c6ebf
parente5fc592c025928b8eda463a2282fbe4cc1fe9288 (diff)
downloadnimgit-910bc779ad1f2fe7fcfbdc6d3b5c871e6084140d.tar.gz
nimgit-910bc779ad1f2fe7fcfbdc6d3b5c871e6084140d.tar.bz2
nimgit-910bc779ad1f2fe7fcfbdc6d3b5c871e6084140d.zip
cleanup examples
-rw-r--r--listAllBranches.nim2
-rw-r--r--listAllCommits.nim6
-rw-r--r--showLastCommit.nim29
3 files changed, 23 insertions, 14 deletions
diff --git a/listAllBranches.nim b/listAllBranches.nim
index 6c53122..735cff5 100644
--- a/listAllBranches.nim
+++ b/listAllBranches.nim
@@ -8,7 +8,7 @@ if paramCount() == 0:
discard git_libgit2_init()
try:
- let gitRepository = openGitRepository(paramStr(1))
+ let gitRepository = openGitRepository(paramStr(1))
for branch in gitRepository.branches(branchAll):
if branch.isLocalBranch():
diff --git a/listAllCommits.nim b/listAllCommits.nim
index 4e2ed96..2dbb0e0 100644
--- a/listAllCommits.nim
+++ b/listAllCommits.nim
@@ -23,10 +23,6 @@ try:
committer = gitCommit.committer
parentCount = gitCommit.parentCount
- var id = 0
-
- echo kind(cast[GitObject](gitCommit))
-
echo "==================="
echo "hash: " & $gitOid
echo "committer: " & committer.name & " <" & committer.email & ">"
@@ -34,6 +30,8 @@ try:
echo "when: " & $author.when.time
echo "message: " & gitCommit.summary
echo "parentCount: " & $parentCount
+
+ var id = 0
if parentCount > 0:
while id < parentCount:
echo "parent: " & $gitCommit.parentId(id)
diff --git a/showLastCommit.nim b/showLastCommit.nim
index 53e0582..78f3a73 100644
--- a/showLastCommit.nim
+++ b/showLastCommit.nim
@@ -8,20 +8,31 @@ if paramCount() == 0:
discard git_libgit2_init()
try:
- let gitRepository = openGitRepository(paramStr(1))
+ let
+ gitRepository = openGitRepository(paramStr(1))
+ objId = gitRepository.lookupObjectIdByName("HEAD")
+ commit = gitRepository.lookupCommit(objId)
+ author = commit.author
+ committer = commit.committer
+ parentCount = commit.parentCount
echo "Last commit on HEAD in repo: " & $gitRepository
-
- let objId = gitRepository.lookupObjectIdByName("HEAD")
- let commit = gitRepository.lookupCommit(objId)
- let author = commit.getAuthor()
-
- echo "hash: " & $commit.getObjectId()
+ echo "==================="
+ echo "hash: " & $objId
+ echo "committer: " & committer.name & " <" & committer.email & ">"
echo "author: " & author.name & " <" & author.email & ">"
echo "when: " & $author.when.time
- echo "message: " & commit.getSummary()
+ echo "message: " & commit.summary
+ echo "parentCount: " & $parentCount
+
+ var id = 0
+ if parentCount > 0:
+ while id < parentCount:
+ echo "parent: " & $commit.parentId(id)
+ inc(id)
+ echo ""
- free(commit);
+ free(commit)
free(gitRepository)
except: