ctucx.git: nimgit

[nimlang] nim-wrapper for libgit2

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
import nimgit2
import types, free, utils, objects

proc lookupTag* (repo: GitRepository, id: GitObjectId): GitTag =
    let error = git_tag_lookup(addr result, repo, id)

    if error != 0:
        free(result)
        raise newException(CatchableError, "Tag lookup failed: " & $error.getResultCode)

proc type* (obj: GitTag): GitObjectKind = cast[GitObject](obj).type

proc owner* (tag: GitTag): GitRepository = git_tag_owner(tag)

proc id* (tag: GitTag): GitObjectId = git_tag_id(tag)

proc shortId* (tag: GitTag): string = cast[GitObject](tag).shortId()

proc name* (tag: GitTag): string = $git_tag_name(tag)

proc message* (tag: GitTag): string = $git_tag_message(tag)

proc tagger* (tag: GitTag): GitSignature = git_tag_tagger(tag).parseGitSignature

proc copy* (tag: GitTag): GitTag =
    let error = git_tag_dup(addr result, tag)

    if error != 0:
        free(result)
        raise newException(CatchableError, "Cannot copy GitTag: " & $error.getResultCode)

proc target* (tag: GitTag): GitObject =
    let error = git_tag_target(addr result, tag)

    if error != 0:
        free(result)
        raise newException(CatchableError, "Cannot get target object: " & $error.getResultCode)

proc targetId* (tag: GitTag): GitObjectId = git_tag_target_id(tag)

proc peelTarget* (tag: GitTag): GitObject =
    let error = git_tag_peel(addr result, tag)

    if error != 0:
        free(result)
        raise newException(CatchableError, "Tag peel failed: " & $error.getResultCode)

proc targetType* (tag: GitTag): GitObjectKind = cast[GitObjectKind](git_tag_target_type(tag))