ctucx.git: nimgit

[nimlang] nim-wrapper for libgit2

commit cf792ed268c47230306ccc18be197f1d05aba0fe
parent e0cc20f7f582d999775ad84ec968a269de532cff
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 17 Mar 2021 11:35:46 +0100

update implemented.txt and listAllCommits.nim
2 files changed, 31 insertions(+), 22 deletions(-)
M
implemented.txt
|
30
++++++++++++++++--------------
M
listAllCommits.nim
|
23
+++++++++++++++--------
diff --git a/implemented.txt b/implemented.txt
@@ -10,16 +10,17 @@ branch.nim             branches                       git_branch_iterator_new
 branch.nim             branches                       git_branch_next
 
 commit.nim             lookupCommit                   git_commit_lookup
-commit.nim             getSummary                     git_commit_summary
-commit.nim             getShortMessage (alias)        git_commit_summary
-commit.nim             getMessage                     git_commit_message
-commit.nim             getObjectId                    git_commit_id
-commit.nim             getAuthor                      git_commit_author
-commit.nim             getCommitter                   git_commit_committer
-commit.nim             getParrentCount                git_commit_parentcount
-commit.nim             getParrent                     git_commit_parent
-commit.nim             getParrentId                   git_commit_parent_id
-commit.nim             getTree                        git_commit_tree
+commit.nim             summary                        git_commit_summary
+commit.nim             body                           git_commit_body
+commit.nim             message                        git_commit_message
+commit.nim             objectId                       git_commit_id
+commit.nim             author                         git_commit_author
+commit.nim             committer                      git_commit_committer
+commit.nim             parentCount                    git_commit_parentcount
+commit.nim             parentId                       git_commit_parent_id
+commit.nim             parent                         git_commit_parent
+commit.nim             treeId                         git_commit_tree_id
+commit.nim             tree                           git_commit_tree
 
 free.nim               free                           git_repository_free
 free.nim               free                           git_reference_free

@@ -67,11 +68,12 @@ reference.nim          getGitReferenceNames           git_reference_list
 
 repository.nim         openGitRepository              git_repository_open
 repository.nim         getHeadForWorktree             git_repository_head_for_worktree
-repository.nim         getHead                        git_repository_head
+repository.nim         head                           git_repository_head
 repository.nim         isHeadDetached                 git_repository_head_detached
-repository.nim         getTagList                     git_tag_list
-repository.nim         getPath                        git_repository_path
-repository.nim         getWorkdir                     git_repository_workdir
+repository.nim         isHeadUnborn                   git_repository_head_unborn
+repository.nim         tagList                        git_tag_list
+repository.nim         path                           git_repository_path
+repository.nim         workdir                        git_repository_workdir
 repository.nim         isEmpty                        git_repository_is_empty
 repository.nim         isWorktree                     git_repository_is_worktree
 repository.nim         isBare                         git_repository_is_bare
diff --git a/listAllCommits.nim b/listAllCommits.nim
@@ -14,23 +14,30 @@ try:
     gitRevisionWalker.sort(GIT_SORT_TOPOLOGICAL)
     gitRevisionWalker.pushHead()
 
-    gitRevisionWalker.simplifyFirstParent()
+    echo "Commits on HEAD in repo: " & $gitRepository
 
     for gitOid in gitRevisionWalker:
-        let gitCommit = gitRepository.lookupCommit(gitOid)
+        let
+          gitCommit    = gitRepository.lookupCommit(gitOid)
+          author       = gitCommit.author
+          committer    = gitCommit.committer
+          parentCount  = gitCommit.parentCount
 
-        let author    = gitCommit.getAuthor()
-        let committer = gitCommit.getCommitter()
+        var id = 0
+
+        echo kind(cast[GitObject](gitCommit))
 
         echo "==================="
         echo "hash: " & $gitOid
         echo "committer: " & committer.name & " <" & committer.email & ">"
         echo "author: " & author.name & " <" & author.email & ">"
         echo "when: " & $author.when.time
-        echo "message: " & gitCommit.getSummary()
-        echo "parrentCount: " & $gitCommit.getParrentCount()
-        if gitCommit.getParrentCount > 0:
-            echo "parrent: " & $gitCommit.getParrent()
+        echo "message: " & gitCommit.summary
+        echo "parentCount: " & $parentCount
+        if parentCount > 0:
+            while id < parentCount:
+                echo "parent: " & $gitCommit.parentId(id)
+                inc(id)
         echo ""
 
         free(gitCommit)