summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-17 02:24:56 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-17 02:24:56 +0100
commitb2fc1ab137ddf5da457942d018ce002037bd7b39 (patch)
tree69157bbb8911dff0d13187a4a2ce895dc7d97acf
parent1e0f00b7546d535d96a0126f9840424a02878486 (diff)
downloadnimgit-b2fc1ab137ddf5da457942d018ce002037bd7b39.tar.gz
nimgit-b2fc1ab137ddf5da457942d018ce002037bd7b39.tar.bz2
nimgit-b2fc1ab137ddf5da457942d018ce002037bd7b39.zip
repository.nim: new procs: getHeadForWorktree, getTagList, isEmpty, isWorktree, isBare, getWorktree
-rw-r--r--nimgit/repository.nim34
1 files changed, 34 insertions, 0 deletions
diff --git a/nimgit/repository.nim b/nimgit/repository.nim
index bfd8b35..18460b1 100644
--- a/nimgit/repository.nim
+++ b/nimgit/repository.nim
@@ -11,6 +11,14 @@ proc openGitRepository* (path: string): GitRepository =
result = repository
+
+proc getHeadForWorktree* (repo: GitRepository, name: string): GitReference =
+ let error = git_repository_head_for_worktree(addr result, repo, cstring(name))
+
+ if error != 0:
+ free(result)
+ raise newException(CatchableError, "Cannot get HEAD for worktree: " & $error.getResultCode)
+
proc getHead* (repo: GitRepository): GitReference =
let error = git_repository_head(addr result, repo)
@@ -20,6 +28,32 @@ proc getHead* (repo: GitRepository): GitReference =
proc isHeadDetached* (repo: GitRepository): bool = cast[bool](git_repository_head_detached(repo))
+
+proc getTagList* (repo: GitRepository): seq[string] =
+ var list: git_strarray
+
+ let error = git_tag_list(addr list, repo)
+
+ if error != 0:
+ free(addr list)
+ raise newException(CatchableError, "Cannot get tagList: " & $error.getResultCode)
+
+ if list.count == 0'u:
+ result = newSeq[string]()
+ else:
+ result = cstringArrayToSeq(cast[cstringArray](list.strings), list.count)
+
+ free(addr list)
+
+
+proc isEmpty* (repo: GitRepository): bool = cast[bool](git_repository_is_empty(repo))
+
+proc isWorktree* (repo: GitRepository): bool = cast[bool](git_repository_is_worktree(repo))
+
+proc isBare* (repo: GitRepository): bool = cast[bool](git_repository_is_bare(repo))
+
proc getPath* (repo: GitRepository): string = $git_repository_path(repo)
+proc getWorkdir* (repo: GitRepository): string = $git_repository_workdir(repo)
+
proc `$`* (repo: GitRepository): string = repo.getPath() \ No newline at end of file