gitx

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 10 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 (
	ErrNotFastForward = errors.New("not a fast-forward")
	ErrMergeConflict  = errors.New("merge conflict")
	ErrDetachedHEAD   = errors.New("HEAD is detached")
)

Functions

func CleanGitEnv

func CleanGitEnv(environment []string) []string

CleanGitEnv is the shared boundary for direct Git/gh integrations outside this package. It removes repository-location variables but preserves normal authentication and locale environment for the caller.

func OwningRepository added in v0.4.0

func OwningRepository(dir string) string

OwningRepository returns the checkout that stores `.git/jacu` runstate. A linked worktree's `.git` file points at `<repo>/.git/worktrees/<id>`; a normal checkout is returned unchanged.

Types

type CommandRunner

type CommandRunner interface {
	Run(ctx context.Context, bin, repo string, env []string, input string, args ...string) (string, string, error)
}

type Commit

type Commit struct {
	Hash           string
	AuthorName     string
	AuthorEmail    string
	CommitterName  string
	CommitterEmail string
	Subject        string
	Body           string
}

Commit is one parsed git-log record. Field order matches the %x1f format in LogCommits.

type Git

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

func New

func New() (*Git, error)

func NewWithRunner

func NewWithRunner(bin string, runner CommandRunner) *Git

func (*Git) ApplyPatch3Way

func (g *Git) ApplyPatch3Way(ctx context.Context, repo, patch string) (bool, error)

ApplyPatch3Way applies one agent patch and reports a content conflict as a value. Mechanical git failures remain errors so the caller can distinguish an expected fan-in collision from a broken repository or command.

func (*Git) ArchiveHead

func (g *Git) ArchiveHead(ctx context.Context, repo string, writer io.Writer) error

func (*Git) BranchDelete

func (g *Git) BranchDelete(ctx context.Context, repo, branch string) error

func (*Git) BranchExists

func (g *Git) BranchExists(ctx context.Context, repo, branch string) (bool, error)

func (*Git) CaptureStagedPatch

func (g *Git) CaptureStagedPatch(ctx context.Context, worktree, baseSHA string) (string, error)

CaptureStagedPatch stages every file before reading the binary patch. The staging step is part of the fan-in contract: without it, newly created files are not blobs in the shared object database and git apply --3way cannot reconstruct their ancestor.

func (*Git) CommitAll

func (g *Git) CommitAll(ctx context.Context, worktree, message string) (string, error)

func (*Git) CommitTree

func (g *Git) CommitTree(ctx context.Context, worktree, expectedParent, treeSHA, message string) (string, error)

func (*Git) CountAhead

func (g *Git) CountAhead(ctx context.Context, repo, baseSHA string) (int, error)

func (*Git) CurrentBranch added in v0.4.0

func (g *Git) CurrentBranch(ctx context.Context, repo string) (string, error)

func (*Git) Diff

func (g *Git) Diff(ctx context.Context, worktree, baseSHA string) (string, error)

func (*Git) DiffNumstat

func (g *Git) DiffNumstat(ctx context.Context, worktree, baseSHA string) (int, int, []string, error)

func (*Git) DiffSnapshot

func (g *Git) DiffSnapshot(ctx context.Context, worktree, baseSHA string) (Snapshot, error)

func (*Git) DiffStaged

func (g *Git) DiffStaged(ctx context.Context, worktree, baseSHA string) (string, error)

func (*Git) DiffTree

func (g *Git) DiffTree(ctx context.Context, worktree, baseSHA, treeSHA string) (string, error)

func (*Git) Exec added in v0.4.0

func (g *Git) Exec(ctx context.Context, repo string, args ...string) error

func (*Git) HasCommits

func (g *Git) HasCommits(ctx context.Context, repo string) bool

func (*Git) HasSubmodules

func (g *Git) HasSubmodules(ctx context.Context, repo string) bool

func (*Git) HasTrackedChanges added in v0.4.0

func (g *Git) HasTrackedChanges(ctx context.Context, repo string) (bool, error)

HasTrackedChanges ignores untracked files, which a merge neither consumes nor overwrites. The checkout that runs autonomy always carries untracked JACU state — `.jacu/autonomy-policy.json` among them — and IsClean would refuse every local merge because of it.

func (*Git) InsideWorkTree

func (g *Git) InsideWorkTree(ctx context.Context, dir string) bool

func (*Git) IsClean added in v0.4.0

func (g *Git) IsClean(ctx context.Context, repo string) (bool, error)

func (*Git) LogCommits

func (g *Git) LogCommits(ctx context.Context, repo, rng string) ([]Commit, error)

func (*Git) LsFiles

func (g *Git) LsFiles(ctx context.Context, repo string) ([]string, error)

func (*Git) MergeAbort added in v0.4.0

func (g *Git) MergeAbort(ctx context.Context, repo string) error

func (*Git) MergeFFOnly added in v0.4.0

func (g *Git) MergeFFOnly(ctx context.Context, repo, branch string) error

func (*Git) MergeNoFF added in v0.4.0

func (g *Git) MergeNoFF(ctx context.Context, repo, branch string) error

func (*Git) Output added in v0.4.0

func (g *Git) Output(ctx context.Context, repo string, args ...string) (string, error)

func (*Git) OutputRaw added in v0.4.0

func (g *Git) OutputRaw(ctx context.Context, repo string, args ...string) (string, error)

func (*Git) ReadOnlyNumstat

func (g *Git) ReadOnlyNumstat(ctx context.Context, worktree, baseSHA string) (int, int, []string, error)

func (*Git) ResetHard

func (g *Git) ResetHard(ctx context.Context, repo, baseSHA string) error

ResetHard restores an owned fan-in target to its known base after a conflict. Fan-in callers must pass the run's authoritative base SHA.

func (*Git) ResetMixed

func (g *Git) ResetMixed(ctx context.Context, worktree string) error

func (*Git) RevParseGitDir added in v0.4.0

func (g *Git) RevParseGitDir(ctx context.Context, repo string) (string, error)

func (*Git) RevParseHead

func (g *Git) RevParseHead(ctx context.Context, repo string) (string, error)

func (*Git) StageAll

func (g *Git) StageAll(ctx context.Context, worktree string) error

func (*Git) StageTree

func (g *Git) StageTree(ctx context.Context, worktree string) (string, error)

func (*Git) StatusPorcelainZ added in v0.4.0

func (g *Git) StatusPorcelainZ(ctx context.Context, repo string) (string, error)

func (*Git) UpdateHeadCAS

func (g *Git) UpdateHeadCAS(ctx context.Context, repo, newSHA, expectedOldSHA string) error

func (*Git) UsesLFS

func (g *Git) UsesLFS(ctx context.Context, repo string) bool

func (*Git) Version

func (g *Git) Version() (string, error)

func (*Git) WorktreeAdd

func (g *Git) WorktreeAdd(ctx context.Context, repo, path, branch, baseSHA string) error

func (*Git) WorktreeAddOwnedBranch

func (g *Git) WorktreeAddOwnedBranch(ctx context.Context, repo, path, branch, baseSHA string) (bool, error)

WorktreeAddOwnedBranch atomically creates branch before attaching it to a worktree. The boolean reports whether this invocation created the branch, so callers can avoid deleting a branch owned by another invocation on failure.

func (*Git) WorktreeInfo

func (g *Git) WorktreeInfo(ctx context.Context, repo, path string) (WorktreeInfo, error)

func (*Git) WorktreeLock

func (g *Git) WorktreeLock(ctx context.Context, repo, path string) error

func (*Git) WorktreePrune

func (g *Git) WorktreePrune(ctx context.Context, repo string) error

func (*Git) WorktreeRemove

func (g *Git) WorktreeRemove(ctx context.Context, repo, path string) error

func (*Git) WorktreeUnlock

func (g *Git) WorktreeUnlock(ctx context.Context, repo, path string) error

type Snapshot

type Snapshot struct {
	Patch   string
	Added   int
	Deleted int
	Files   []string
}

type WorktreeInfo

type WorktreeInfo struct {
	Registered bool
	Locked     bool
	Branch     string
}

Jump to

Keyboard shortcuts

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