Skip to content

Version 0.3.0

A Git repository, read from first principles.

Thuban reads and writes Git data directly from Ruby, then fetches and pushes local, smart HTTP, and SSH remotes through bounded transports.

Runtime
Ruby 3.1+
Repository format
SHA-1
Runtime dependencies
1
Repository map HEAD → main
Git object relationship The main branch reference points to a commit, which points to a tree and then a blob. The index also references the blob. object database / loose + packed refs/heads/main symbolic ref commit tree / parent / author tree 100644 blob README.md blob README contents index mode 100644 / blob

The repository is the API.

Thuban keeps Git concepts visible. Ask for a ref, commit, tree, blob, or status entry and get a Ruby value back.

repo.object

Read the object database

Resolve refs and inspect loose or packed commits, trees, and blobs, including both Git delta encodings.

repo.status

Understand working state

Compare HEAD, the index, and the worktree while respecting repository ignore rules and linked worktrees.

repo.checkout

Write within a hard boundary

Replace worktree files atomically or switch branches only after Thuban rules out dirty files and path collisions.

reader.rb Ruby
require "thuban"

repo = Thuban::Repository.new(".")

repo.branch
# => "main"

repo.blob("README.md")
repo.status
repo.blame("lib/thuban.rb")

Small surface. Explicit composition.

Diffing stays outside the reader. Thuban delegates line matching to Porrima, its only runtime dependency, and accepts an injected differ for blame.

Use staged_blob and worktree_content when you need to compare or restore text explicitly.

Read the design decision

Narrow by intent.

Thuban reads and writes local repositories, and transfers refs over local, smart HTTP, and SSH remotes. Fetches can report progress, limit history depth, or omit blobs. It targets SHA-1 repositories and the index and pack formats exercised by its test suite.

  • Bounded remote transfers
  • Shallow and blobless fetches
  • No merge or rebase engine
  • No submodule checkout
  • No built-in diff algorithm

Read the repository beneath your tools.

Start with the public API, then follow each Git object as far down as your application needs.

Get Thuban 0.1.0