git

package
v0.91.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: EUPL-1.2 Imports: 14 Imported by: 0

Documentation

Overview

Package git implements ports.ConfigRepo against the system git binary. Every operation is an exec with an argument vector (no shell), scoped to the repo directory with -C. The adapter never interprets file contents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoteHead added in v0.65.3

func RemoteHead(ctx context.Context, remote string) (string, error)

RemoteHead resolves the HEAD revision of an arbitrary remote without a local clone - the upstream watcher's one git need.

Types

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Repo is one git working tree acting as a config repo.

func Open

func Open(dir, remote string) (*Repo, error)

Open returns a Repo for an existing working tree. The directory must contain a git repository (a .git directory, or a .git file for a linked worktree); callers provision repos out of band.

func (*Repo) AddWorktree

func (r *Repo) AddWorktree(ctx context.Context, dir, branch string) error

AddWorktree implements ports.BranchRepo. Same "--" guard as CreateBranch: it stops a dir/branch starting with "-" from being misread as a flag.

func (*Repo) BranchMerged added in v0.79.0

func (r *Repo) BranchMerged(ctx context.Context, branch string) (bool, error)

BranchMerged implements ports.BranchRepo. Answers from git, which is the authority on whether a merge happened.

Deliberately two calls rather than "merge-base --is-ancestor": that reports its answer through the EXIT CODE, and this package's git helper turns any non-zero exit into a message, so "not an ancestor" and "no such branch" would arrive indistinguishable. They are different answers, and conflating them would let a deleted branch read as "not merged" - leaving a change in Ready forever, the opposite of the reconciliation this serves.

func (*Repo) Commit

func (r *Repo) Commit(ctx context.Context, msg string, a ports.Author, files ...string) error

Commit implements ports.ConfigRepo. The author comes from the session so the audit trail names a person, with a service fallback.

func (*Repo) CommitCount added in v0.65.3

func (r *Repo) CommitCount(ctx context.Context, rev string) (int, error)

CommitCount returns the number of commits reachable from rev - a monotonic "release number" for lineage-ordered revisions on one branch. Humans compare 142 vs 145 at a glance where two sha prefixes say nothing.

func (*Repo) CreateBranch

func (r *Repo) CreateBranch(ctx context.Context, name string) error

CreateBranch implements ports.BranchRepo. The "--" stops a name starting with "-" from being misread as a flag (mirrors Commit's "git add --").

func (*Repo) DeleteBranch

func (r *Repo) DeleteBranch(ctx context.Context, name