local

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package local implements backend.Repo for a repository on disk by driving the git command line. Every call is one or two short-lived git child processes; git itself is safe for concurrent readers, so the type holds no locks beyond a small cache for recursive file listings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

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

Repo drives git for one repository.

func New

func New(ctx context.Context, dir string) (*Repo, error)

New validates dir as a git repository and derives its identity.

func (*Repo) AheadBehind

func (r *Repo) AheadBehind(ctx context.Context, rev, base string) (ahead, behind int, err error)

AheadBehind reports how many commits rev has that base lacks and the reverse. The server uses it on the branches page; it is not part of the backend contract.

func (*Repo) Archive

func (r *Repo) Archive(ctx context.Context, rev, format, prefix string, w io.Writer) error

func (*Repo) Blame

func (r *Repo) Blame(ctx context.Context, rev, pth string) ([]backend.BlameHunk, error)

Blame parses `git blame --porcelain`. The porcelain stream emits, per line, a "<sha> <orig> <final> [<n>]" header where <n> appears only on the first line of a hunk, followed by key-value commit fields the first time a commit is seen, then the content line prefixed with a tab.

func (*Repo) Blob

func (r *Repo) Blob(ctx context.Context, rev, pth string) (backend.Blob, error)

func (*Repo) Commit

func (r *Repo) Commit(ctx context.Context, sha string) (backend.CommitDetail, error)

Commit returns one commit with its diff against the first parent, or against the empty tree for a root commit, the way github.com renders commit pages.

func (*Repo) CommitCount

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

CommitCount reports how many commits are reachable from rev. The server uses this for the "N commits" header link via an optional interface.

func (*Repo) Commits

func (r *Repo) Commits(ctx context.Context, rev, pth string, n, skip int) ([]backend.Commit, bool, error)

func (*Repo) Files

func (r *Repo) Files(ctx context.Context, rev string) ([]string, error)

func (*Repo) Info

func (r *Repo) Info(ctx context.Context) (backend.Info, error)

func (*Repo) LastCommit

func (r *Repo) LastCommit(ctx context.Context, rev, pth string) (backend.Commit, error)

func (*Repo) Refs

func (r *Repo) Refs(ctx context.Context) (backend.Refs, error)

func (*Repo) Resolve

func (r *Repo) Resolve(ctx context.Context, ref string) (string, error)

Resolve maps a ref name or hex prefix to a full commit SHA. Branches win over tags, matching github.com, and revision-walk syntax is rejected.

func (*Repo) Tree

func (r *Repo) Tree(ctx context.Context, rev, pth string) ([]backend.TreeEntry, error)

Jump to

Keyboard shortcuts

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