gittyup
This is a higher-level and idiomatic abstraction for libgit2 that builds upon the nimgit2 wrapper produced by nimterop.
Exceptional Support ... so to speak
Supported on Linux, OS X, and Windows, with the following caveats:
nim-1.5.1 c --os:windows
Unsupported due to apparent Nimterop issues.
cpp --cc:clang --define:git2Static
Unsupported due to codegen bug. Note that this generally includes MacOSX.
cpp --gc:arc
Unsupported due to ARC codegen bug.
Usage
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 automaticallyInstallation
$ nimph clone gittyup
or if you're still using Nimble like it's 2012,
$ nimble install https://github.com/disruptek/gittyup
Documentation
See the documentation for the gittyup module as generated directly from the source. I often find the libgit2 reference documentation site useful as well.
License
MIT

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
