This is a higher-level and idiomatic abstraction for libgit2 that builds upon the nimgit2 wrapper produced by nimterop.
Supported on Linux, OS X, and Windows, with the following caveats:
Unsupported due to apparent Nimterop issues.
Unsupported due to codegen bug. Note that this generally includes MacOSX.
Unsupported due to ARC codegen bug.
You need a libgit2
>= 1.0.0
and 1.1.0
is the latest supported release; I
recommend this combination of build flags:
# build libraries from scratch using the libgit2 repo
--define:git2Git --define:git2SetVer="v1.1.0"
These don't work for me due to apparent Nimterop issues:
# use your system's libgit2
--define:git2Std --define:git2SetVer="1.0.1"
These may be useful to provide SSH support on Windows:
# use pre-built Julia Binaries
--define:git2JBB --define:git2SetVer="1.0.1"
This gives some idea for the usage:
import gittyup
# a simple example of cloning a repo
block cloning:
let
url = parseURI"https://github.com/disruptek/gittyup"
dir = "/some/where/gitty"
# perform a clone; repo is a GitRepository object
repo := clone(url, dir):
# this is your error handler;
# code is an enum of GitResultCode
case code:
of grcExists:
error dir, " already exists, i guess"
of grcNotFound:
error url, " isn't a git url, maybe"
else:
# an error string more specific than $code
error code.dumpError
# you don't have to leave, but i recommend it
break
# repo is symbol pointing to a GitRepository here
# "manual" call invocation means you perform your
# own memory work, but it's sometimes more ideal
let
head = repo.headReference
# using result semantics...
if head.isErr:
echo "error code: ", head.error
else:
echo "head oid: ", head.get.oid
# repo is now out of scope and will be freed automatically
$ nimph clone gittyup
or if you're still using Nimble like it's 2012,
$ nimble install https://github.com/disruptek/gittyup
See the documentation for the gittyup module as generated directly from the source. I often find the libgit2 reference documentation site useful as well.
MIT