summaryrefslogtreecommitdiffstats
path: root/nimgit/treeEntry.nim
blob: 8dd30e24973d4e509e8bb8144cea72c5a55a6554 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import nimgit2
import types, free, utils

proc type* (entry: GitTreeEntry): GitObjectKind = GitObjectKind(git_tree_entry_type(entry) - GIT_OBJECT_ANY)

proc id* (entry: GitTreeEntry): GitObjectId = git_tree_entry_id(entry)

proc name* (entry: GitTreeEntry): string = $git_tree_entry_name(entry)

proc mode* (entry: GitTreeEntry): int = cast[int](git_tree_entry_filemode(entry))

proc getObject* (repo: GitRepository, entry: GitTreeEntry): GitObject =
    let error = git_tree_entry_to_object(addr result, repo, entry)

    if error != 0:
        free(result)
        raise newException(CatchableError, "Cannot convert tree-entry into object: " & $error.getResultCode)