git

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: GPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupported = errors.New("git: operation not supported on this backend")
	ErrNotARepo    = errors.New("git: not inside a git repository")
	ErrNoGitCLI    = errors.New("git: `git` binary not on PATH and go-git fallback unavailable")
)

Functions

func FindRepo

func FindRepo(start string) (string, error)

Types

type CLIRepo

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

func NewCLIRepo

func NewCLIRepo(root string) (*CLIRepo, error)

func (*CLIRepo) BranchDiff

func (r *CLIRepo) BranchDiff(target string) (Diff, error)

func (*CLIRepo) CommitDiff

func (r *CLIRepo) CommitDiff(hash string) (Diff, error)

func (*CLIRepo) Diff added in v0.9.0

func (r *CLIRepo) Diff(args []string) (Diff, error)

Diff is the generic `git diff <args>` passthrough used by the `commitbrief diff` subcommand. We always inject `--no-color` and `--no-ext-diff` so the parser/renderer pipeline sees the same stable unified-diff shape the other Diff*() helpers produce. The caller is responsible for validating args (e.g. requiring at least one positional ref) — empty args yields `git diff` (i.e. unstaged), which is identical to UnstagedDiff() and discouraged.

func (*CLIRepo) FileDiff

func (r *CLIRepo) FileDiff(path string) (Diff, error)

func (*CLIRepo) RangeDiff

func (r *CLIRepo) RangeDiff(target, feature string) (Diff, error)

func (*CLIRepo) Root

func (r *CLIRepo) Root() string

func (*CLIRepo) StagedDiff

func (r *CLIRepo) StagedDiff() (Diff, error)

func (*CLIRepo) UnstagedDiff

func (r *CLIRepo) UnstagedDiff() (Diff, error)

type Diff

type Diff struct {
	Content string
	Origin  Origin
	Args    map[string]string
}

func (Diff) Empty

func (d Diff) Empty() bool

type DispatchOptions

type DispatchOptions struct {
	Logger *slog.Logger
}

type DispatchRepo

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

func Open

func Open(root string, opts DispatchOptions) (*DispatchRepo, error)

func (*DispatchRepo) BranchDiff

func (d *DispatchRepo) BranchDiff(target string) (Diff, error)

func (*DispatchRepo) CommitDiff

func (d *DispatchRepo) CommitDiff(hash string) (Diff, error)

func (*DispatchRepo) Diff added in v0.9.0

func (d *DispatchRepo) Diff(args []string) (Diff, error)

func (*DispatchRepo) FileDiff

func (d *DispatchRepo) FileDiff(path string) (Diff, error)

func (*DispatchRepo) RangeDiff

func (d *DispatchRepo) RangeDiff(target, feature string) (Diff, error)

func (*DispatchRepo) Root

func (d *DispatchRepo) Root() string

func (*DispatchRepo) StagedDiff

func (d *DispatchRepo) StagedDiff() (Diff, error)

func (*DispatchRepo) UnstagedDiff

func (d *DispatchRepo) UnstagedDiff() (Diff, error)

type GoGitRepo

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

func NewGoGitRepo

func NewGoGitRepo(root string) (*GoGitRepo, error)

func (*GoGitRepo) BranchDiff

func (g *GoGitRepo) BranchDiff(target string) (Diff, error)

func (*GoGitRepo) CommitDiff

func (g *GoGitRepo) CommitDiff(hash string) (Diff, error)

func (*GoGitRepo) Diff added in v0.9.0

func (g *GoGitRepo) Diff([]string) (Diff, error)

Diff (arbitrary `git diff <args>` passthrough) is intentionally unsupported on the go-git backend — re-implementing every git diff CLI shorthand (HEAD, A..B, A...B, --merge-base, etc.) by hand would balloon the surface area and drift. DispatchRepo falls back to the CLI here.

func (*GoGitRepo) FileDiff

func (g *GoGitRepo) FileDiff(string) (Diff, error)

func (*GoGitRepo) RangeDiff

func (g *GoGitRepo) RangeDiff(target, feature string) (Diff, error)

func (*GoGitRepo) Root

func (g *GoGitRepo) Root() string

func (*GoGitRepo) StagedDiff

func (g *GoGitRepo) StagedDiff() (Diff, error)

func (*GoGitRepo) UnstagedDiff

func (g *GoGitRepo) UnstagedDiff() (Diff, error)

type Origin

type Origin string
const (
	OriginStaged   Origin = "staged"
	OriginUnstaged Origin = "unstaged"
	OriginFile     Origin = "file"
	OriginCommit   Origin = "commit"
	OriginRange    Origin = "range"
	OriginBranch   Origin = "branch"
	OriginDiff     Origin = "diff" // `commitbrief diff <args...>` passthrough
)

type Repo

type Repo interface {
	StagedDiff() (Diff, error)
	UnstagedDiff() (Diff, error)
	FileDiff(path string) (Diff, error)
	CommitDiff(hash string) (Diff, error)
	RangeDiff(target, feature string) (Diff, error)
	BranchDiff(target string) (Diff, error)
	// Diff is the generic `git diff <args>` passthrough used by the
	// `commitbrief diff` subcommand. args are forwarded verbatim
	// after `--no-color --no-ext-diff` so the renderer/parser see
	// stable unified-diff output. Backends that can't faithfully
	// implement arbitrary git arg combinations may return
	// ErrUnsupported; the DispatchRepo then falls through to the
	// CLI path.
	Diff(args []string) (Diff, error)
	Root() string
}

Jump to

Keyboard shortcuts

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