commit 910bc779ad1f2fe7fcfbdc6d3b5c871e6084140d
parent e5fc592c025928b8eda463a2282fbe4cc1fe9288
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 17 Mar 2021 16:34:24 +0100
parent e5fc592c025928b8eda463a2282fbe4cc1fe9288
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 17 Mar 2021 16:34:24 +0100
cleanup examples
3 files changed, 23 insertions(+), 14 deletions(-)
diff --git 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 @@ -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 @@ -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: