agate

Version, currently 0.1.13 versions

gitlab.com/bjjb/agate

Crystal bindings to libgit2, inspired by rugged

1 stars
0 dependents
License: MIT

Nothing has been indexed for 0.1.1 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  agate:
    gitlab: bjjb/agate
    version: ~> 0.1.1

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.1. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

Agate

Crystal bindings to libgit2, inspired by Rugged.

pipeline status

Prerequisites

Install libgit2 via your package manager:

# macOS
brew install libgit2

# Alpine
apk add libgit2-dev

# Ubuntu / Debian
apt-get install libgit2-dev

# FreeBSD
pkg install libgit2

Installation

Add the dependency to your shard.yml:

dependencies:
  agate:
    gitlab: bjjb/agate

Then run shards install.

Note: shards install does not install libgit2 itself — you must install it via your system package manager (see Prerequisites above).

Usage

require "agate"

# Open an existing repository
repo = Agate::Repository.open("/path/to/repo")

# Initialize a new repository
repo = Agate::Repository.init("/path/to/new/repo") do |opts|
  opts.initial_head = "main"
  opts.mkpath = true
end

# Read HEAD
commit = repo.last_commit
commit.message  # => "Initial commit\n"
commit.author   # => Agate::Signature(@name="...", @email="...")

# Stage and commit
index = repo.index
index.add("README.md")
index.write
tree = Agate::Tree.lookup(repo, index.write_tree)
sig = Agate::Signature.now("Name", "email@example.com")
Agate::Commit.create(repo, "Add README", tree, sig, sig, [commit])

# Diff
diff = commit.diff(repo)
diff.patch  # => "diff --git a/..."

# Clone
cloned = Agate::Repository.clone_at("https://gitlab.com/user/repo.git", "/tmp/repo")

# Branches, tags, remotes
repo.branches.each { |b| puts b.name }
repo.tags.each { |t| puts t.name }
repo.remotes.each { |r| puts "#{r.name}: #{r.url}" }

API Documentation

Full API docs are available at crystaldoc.info.

Contributing

See src/README.md for the source code style guide and spec/README.md for testing conventions.

crystal tool format   # format code
./bin/ameba           # run linter
crystal spec          # run tests

See BUILDING.md for Docker-based cross-platform testing.

License

MIT — Copyright (c) 2025 JJ Buckley