gitref

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangedPathsBetweenRefs

func ChangedPathsBetweenRefs(ctx context.Context, repoPath, leftRef, rightRef string) ([]string, error)

func ChangedPathsFromRefToWorktree

func ChangedPathsFromRefToWorktree(ctx context.Context, repoPath, leftRef string) ([]string, error)

func WorktreePathsMatchRevision added in v0.2.0

func WorktreePathsMatchRevision(ctx context.Context, input PathDigestInput) (bool, error)

WorktreePathsMatchRevision reports whether the worktree content of every requested repository-relative path matches the committed content at Revision: identical tracked file content under each path and no extra worktree files inside requested directories. Symlinks, submodules, and other unsupported modes fail closed (false). Errors mean the comparison could not be completed; callers must treat that as a mismatch.

Types

type PathDigestInput added in v0.2.0

type PathDigestInput struct {
	RepoPath string
	Revision string
	Paths    []PathDigestPath
}

type PathDigestPath added in v0.2.0

type PathDigestPath struct {
	Path     string
	Optional bool
}

type PathDigestResult added in v0.2.0

type PathDigestResult struct {
	Digest   string
	Revision string
}

func CommittedPathDigest added in v0.2.0

func CommittedPathDigest(ctx context.Context, input PathDigestInput) (PathDigestResult, error)

CommittedPathDigest returns a stable digest for repository-relative paths in a committed Git tree. It reads Git object identity only, not worktree files.

type Request

type Request struct {
	Repo           string
	Ref            string
	ForbiddenRoots []string
}

type Result

type Result struct {
	Path     string
	Revision string
	Cleanup  func() error
}

func Snapshot

func Snapshot(ctx context.Context, request Request) (Result, error)

type WorktreeChangeSetResult added in v0.2.0

type WorktreeChangeSetResult struct {
	State      WorktreeState
	Revision   string
	DirtyPaths []string
}

WorktreeChangeSetResult holds the complete dirty-path enumeration for a worktree. DirtyPaths lists every repository-relative path whose worktree state differs from HEAD: modified, deleted, mode-flipped, or type-changed tracked files, plus every extra file (untracked, ignored, and files under untracked directories). A nested .git directory is recorded as a single dirty path without descending into it. Sorted, deduplicated, and empty exactly when State is clean. Completeness is load-bearing: per-path-set cache keying serves committed-key hits for path sets that no dirty path touches, so a missed category here would become a stale cache hit.

func WorktreeChangeSet added in v0.2.0

func WorktreeChangeSet(ctx context.Context, repoPath string) (WorktreeChangeSetResult, error)

WorktreeChangeSet classifies repoPath and enumerates every dirty path. It cannot short-circuit at the first difference because callers need the full set. Non-repository roots report unknown without failing.

type WorktreeState added in v0.2.0

type WorktreeState string

WorktreeState classifies the worktree relative to HEAD.

const (
	WorktreeStateClean   WorktreeState = "clean"
	WorktreeStateDirty   WorktreeState = "dirty"
	WorktreeStateUnknown WorktreeState = "unknown"
)

Jump to

Keyboard shortcuts

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