The Wayback Machine - https://web.archive.org/web/20210129070845/https://github.com/disruptek/gittyup
Skip to content
master
Go to file
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
Jan 16, 2021
Dec 30, 2019
Dec 30, 2019

README.md

gittyup

Test Matrix GitHub release (latest by date) Minimum supported Nim version License buy me a coffee

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 automatically

Installation

$ 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