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 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 import times
import nimgit2

type
    GitRepository*      = ptr git_repository
    GitConfig*          = ptr git_config
    GitConfigEntry*     = ptr git_config_entry
    GitObject*          = ptr git_object
    GitObjectId*        = ptr git_oid
    GitCommit*          = ptr git_commit
    GitTree*            = ptr git_tree
    GitTreeEntry*       = ptr git_tree_entry
    GitReference*       = ptr git_reference
    GitRevisionWalker*  = ptr git_revwalk
    GitBranchIterator*  = ptr git_branch_iterator
    GitBuffer*          = ptr git_buf
    GitTag*             = ptr git_tag
    GitBlob*            = ptr git_blob
    GitDiff*            = ptr git_diff
    GitDiffOptions*     = ptr git_diff_options
    GitDiffFindOptions* = ptr git_diff_find_options
    GitDiffDelta*       = ptr git_diff_delta
    GitPatch*           = ptr git_patch
    GitDiffHunk*        = ptr git_diff_hunk
    GitDiffLine*        = ptr git_diff_line

    GitDiffStats* = object
        filesChanged* : int
        insertions*   : int
        deletions*    : int

    GitObjectKind* = enum
        # we have to add 2 here to satisfy nim; discriminants.low must be zero
        goAny         = (2 + GIT_OBJECT_ANY, "object")        # -2
        goInvalid     = (2 + GIT_OBJECT_INVALID, "invalid")   # -1
        # this space intentionally left blank
        goCommit      = (2 + GIT_OBJECT_COMMIT, "commit")     #  1
        goTree        = (2 + GIT_OBJECT_TREE, "tree")         #  2
        goBlob        = (2 + GIT_OBJECT_BLOB, "blob")         #  3
        goTag         = (2 + GIT_OBJECT_TAG, "tag")           #  4
        # this space intentionally left blank
        goOfsDelta    = (2 + GIT_OBJECT_OFS_DELTA, "ofs")     #  6
        goRefDelta    = (2 + GIT_OBJECT_REF_DELTA, "ref")     #  7

    GitTime* = object
        time*     : Time
        offset*   : int

    GitSignature* = object
        name*   : string
        email*  : string
        `when`* : GitTime

    GitReferenceType* = enum
        referenceDirect   = (GIT_REFERENCE_DIRECT, "direct")
        referenceSymbolic = (GIT_REFERENCE_SYMBOLIC, "symbolic")

    GitBranchType* = enum
        branchLocal  = (GIT_BRANCH_LOCAL, "local")
        branchRemote = (GIT_BRANCH_REMOTE, "remote")
        branchAll    = (GIT_BRANCH_ALL, "all")

    GitReturnCode* = enum
        grcApplyFail       = (GIT_EAPPLYFAIL, "patch failed")
        grcIndexDirty      = (GIT_EINDEXDIRTY, "dirty index")
        grcMismatch        = (GIT_EMISMATCH, "hash mismatch")
        grcRetry           = (GIT_RETRY, "retry")
        grcIterOver        = (GIT_ITEROVER, "end of iteration")
        grcPassThrough     = (GIT_PASSTHROUGH, "pass-through")
        grcMergeConflict   = (GIT_EMERGE_CONFLICT, "merge conflict")
        grcDirectory       = (GIT_EDIRECTORY, "directory")
        grcUncommitted     = (GIT_EUNCOMMITTED, "uncommitted")
        grcInvalid         = (GIT_EINVALID, "invalid")
        grcEndOfFile       = (GIT_EEOF, "end-of-file")
        grcPeel            = (GIT_EPEEL, "peel")
        grcApplied         = (GIT_EAPPLIED, "applied")
        grcCertificate     = (GIT_ECERTIFICATE, "certificate")
        grcAuthentication  = (GIT_EAUTH, "authentication")
        grcModified        = (GIT_EMODIFIED, "modified")
        grcLocked          = (GIT_ELOCKED, "locked")
        grcConflict        = (GIT_ECONFLICT, "conflict")
        grcInvalidSpec     = (GIT_EINVALIDSPEC, "invalid spec")
        grcNonFastForward  = (GIT_ENONFASTFORWARD, "not fast-forward")
        grcUnmerged        = (GIT_EUNMERGED, "unmerged")
        grcUnbornBranch    = (GIT_EUNBORNBRANCH, "unborn branch")
        grcBareRepo        = (GIT_EBAREREPO, "bare repository")
        grcUser            = (GIT_EUSER, "user-specified")
        grcBuffer          = (GIT_EBUFS, "buffer overflow")
        grcAmbiguous       = (GIT_EAMBIGUOUS, "ambiguous match")
        grcExists          = (GIT_EEXISTS, "object exists")
        grcNotFound        = (GIT_ENOTFOUND, "not found")
        grcError           = (GIT_ERROR, "generic error")
        grcOk              = (GIT_OK, "ok")

    GitErrorClass* = enum
        gecNone        = (GIT_ERROR_NONE, "none")
        gecNoMemory    = (GIT_ERROR_NOMEMORY, "no memory")
        gecOS          = (GIT_ERROR_OS, "os")
        gecInvalid     = (GIT_ERROR_INVALID, "invalid")
        gecReference   = (GIT_ERROR_REFERENCE, "reference")
        gecZlib        = (GIT_ERROR_ZLIB, "zlib")
        gecRepository  = (GIT_ERROR_REPOSITORY, "repository")
        gecConfig      = (GIT_ERROR_CONFIG, "config")
        gecRegEx       = (GIT_ERROR_REGEX, "regex")
        gecODB         = (GIT_ERROR_ODB, "odb")
        gecIndex       = (GIT_ERROR_INDEX, "index")
        gecObject      = (GIT_ERROR_OBJECT, "object")
        gecNet         = (GIT_ERROR_NET, "network")
        gecTag         = (GIT_ERROR_TAG, "tag")
        gecTree        = (GIT_ERROR_TREE, "tree")
        gecIndexer     = (GIT_ERROR_INDEXER, "indexer")
        gecSSL         = (GIT_ERROR_SSL, "ssl")
        gecSubModule   = (GIT_ERROR_SUBMODULE, "submodule")
        gecThread      = (GIT_ERROR_THREAD, "thread")
        gecStash       = (GIT_ERROR_STASH, "stash")
        gecCheckOut    = (GIT_ERROR_CHECKOUT, "check out")
        gecFetchHead   = (GIT_ERROR_FETCHHEAD, "fetch head")
        gecMerge       = (GIT_ERROR_MERGE, "merge")
        gecSSH         = (GIT_ERROR_SSH, "ssh")
        gecFilter      = (GIT_ERROR_FILTER, "filter")
        gecRevert      = (GIT_ERROR_REVERT, "revert")
        gecCallBack    = (GIT_ERROR_CALLBACK, "call back")
        gecCherryPick  = (GIT_ERROR_CHERRYPICK, "cherry pick")
        gecDescribe    = (GIT_ERROR_DESCRIBE, "describe")
        gecReBase      = (GIT_ERROR_REBASE, "re-base")
        gecFileSystem  = (GIT_ERROR_FILESYSTEM, "filesystem")
        gecPatch       = (GIT_ERROR_PATCH, "patch")
        gecWorkTree    = (GIT_ERROR_WORKTREE, "work tree")
        gecSHA1        = (GIT_ERROR_SHA1, "sha1")

    GitErrorObj* = object
        message* :  string
        class*   :  GitErrorClass

template getResultCode* (code: cint): GitReturnCode = cast[GitReturnCode](code.ord)
template getErrorClass* (code: cint): GitErrorClass = cast[GitErrorClass](code.ord)