gitio

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package gitio wraps the git CLI for the small set of operations histomancer actually needs: opening or initialising a repo, reading the branch tip and the file at it, running a fast-import stream against the repo, and pushing.

It deliberately shells out to git rather than linking a library, because the git CLI is the lowest-common-denominator everyone already has installed and fast-import is the documented integration boundary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

type Repo struct {
	Path string // absolute path to the repository working tree
}

Repo is an opened or freshly initialised git repository on the local disk.

func Init

func Init(path, branch string) (*Repo, error)

Init creates a new empty git repository at path with branch as the initial branch name and returns a handle to it.

func Open

func Open(path string) (*Repo, error)

Open verifies that path contains a git repository and returns a handle.

func (*Repo) Config

func (r *Repo) Config(key string) (string, error)

Config returns the value of a git config key (e.g. "user.email"), cascading through local → global → system per git's normal lookup. Returns "" with no error when the key is unset, so callers can distinguish "missing" from a hard read failure.

func (*Repo) FileAtHead

func (r *Repo) FileAtHead(branch, repoPath string) ([]byte, error)

FileAtHead returns the contents of repoPath at the tip of branch. Returns (nil, nil) if the file does not exist at that revision (no error — that's the natural starting state).

func (*Repo) HeadSHA

func (r *Repo) HeadSHA(branch string) (string, error)

HeadSHA returns the SHA of the tip of branch, or an empty string if the branch does not exist yet (which is the expected state in fresh mode).

func (*Repo) Push

func (r *Repo) Push(remote, branch string) error

Push pushes branch to remote.

func (*Repo) RunFastImport

func (r *Repo) RunFastImport(write func(stdin io.Writer) error) error

RunFastImport spawns `git fast-import --done` against the repo and invokes write with its stdin. write should finalize the stream with the encoder's Done() — RunFastImport closes the pipe and waits for git to exit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL