gitcommit

package
v0.9.26 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package gitcommit provides the host-owned Git transaction used by native commit workflows. It deliberately has no UI or HTTP dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FingerprintsEqual

func FingerprintsEqual(a, b Fingerprint) bool

func IsKind

func IsKind(err error, kind ErrorKind) bool

func ValidateSelectionPaths

func ValidateSelectionPaths(state RepositoryState, paths []string) error

ValidateSelectionPaths validates model/user paths without mutating the index.

Types

type Change

type Change struct {
	Path            string     `json:"path"`
	OldPath         string     `json:"old_path,omitempty"`
	Kind            ChangeKind `json:"kind"`
	Staged          bool       `json:"staged,omitempty"`
	Unstaged        bool       `json:"unstaged,omitempty"`
	Untracked       bool       `json:"untracked,omitempty"`
	PartiallyStaged bool       `json:"partially_staged,omitempty"`
	Submodule       bool       `json:"submodule,omitempty"`
	Additions       int        `json:"additions,omitempty"`
	Deletions       int        `json:"deletions,omitempty"`
	Binary          bool       `json:"binary,omitempty"`
}

type ChangeKind

type ChangeKind string
const (
	ChangeModified    ChangeKind = "modified"
	ChangeAdded       ChangeKind = "added"
	ChangeDeleted     ChangeKind = "deleted"
	ChangeRenamed     ChangeKind = "renamed"
	ChangeCopied      ChangeKind = "copied"
	ChangeTypeChanged ChangeKind = "type_changed"
	ChangeUntracked   ChangeKind = "untracked"
	ChangeConflicted  ChangeKind = "conflicted"
)

type CommitResult

type CommitResult struct {
	BeforeHead       string `json:"before_head,omitempty"`
	HeadOID          string `json:"head_oid"`
	TreeOID          string `json:"tree_oid"`
	ShortOID         string `json:"short_oid"`
	Subject          string `json:"subject"`
	Message          string `json:"message"`
	TreeChanged      bool   `json:"tree_changed"`
	OutcomeUncertain bool   `json:"outcome_uncertain"`
	Stdout           string `json:"stdout,omitempty"`
	Stderr           string `json:"stderr,omitempty"`
}

type DiffSummary

type DiffSummary struct {
	Files       int `json:"files"`
	Additions   int `json:"additions"`
	Deletions   int `json:"deletions"`
	BinaryFiles int `json:"binary_files"`
}

type Error

type Error struct {
	Kind    ErrorKind `json:"kind"`
	Message string    `json:"message"`
	Output  string    `json:"output,omitempty"`
	Cause   error     `json:"-"`
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorKind

type ErrorKind string
const (
	ErrGitMissing           ErrorKind = "git_missing"
	ErrNotRepository        ErrorKind = "not_repository"
	ErrBareRepository       ErrorKind = "bare_repository"
	ErrUnsafeRepository     ErrorKind = "unsafe_repository"
	ErrConflict             ErrorKind = "conflict"
	ErrUnsupportedOperation ErrorKind = "unsupported_operation"
	ErrIntentToAdd          ErrorKind = "intent_to_add"
	ErrEmptyIndex           ErrorKind = "empty_index"
	ErrStale                ErrorKind = "stale"
	ErrInvalidSelection     ErrorKind = "invalid_selection"
	ErrIndexLock            ErrorKind = "index_lock"
	ErrMissingIdentity      ErrorKind = "missing_identity"
	ErrHook                 ErrorKind = "hook_failure"
	ErrSigning              ErrorKind = "signing_failure"
	ErrCommit               ErrorKind = "commit_failure"
	ErrUncertain            ErrorKind = "uncertain_outcome"
	ErrOutputLimit          ErrorKind = "output_limit"
)

type Fingerprint

type Fingerprint struct {
	CheckoutID string               `json:"checkout_id"`
	HeadState  HeadState            `json:"head_state"`
	HeadOID    string               `json:"head_oid,omitempty"`
	IndexTree  string               `json:"index_tree"`
	Operation  OperationFingerprint `json:"operation"`
}

type HeadState

type HeadState string
const (
	HeadBorn   HeadState = "born"
	HeadUnborn HeadState = "unborn"
)

type MutationCoordinator

type MutationCoordinator interface {
	Acquire(context.Context, string) (func(), error)
}

type OperationFingerprint

type OperationFingerprint struct {
	Kind     OperationKind `json:"kind"`
	HeadOIDs []string      `json:"head_oids"`
	Digest   string        `json:"digest"`
}

type OperationKind

type OperationKind string
const (
	OperationNone       OperationKind = "none"
	OperationMerge      OperationKind = "merge"
	OperationCherryPick OperationKind = "cherry_pick"
	OperationRevert     OperationKind = "revert"
	OperationRebase     OperationKind = "rebase"
	OperationSequencer  OperationKind = "sequencer"
)

type OperationState

type OperationState struct {
	Kind        OperationKind `json:"kind"`
	Description string        `json:"description,omitempty"`
}

type Repository

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

func Open

func Open(ctx context.Context, dir string) (*Repository, error)

func OpenWithCoordinator

func OpenWithCoordinator(ctx context.Context, dir string, coordinator MutationCoordinator) (*Repository, error)

func (*Repository) CheckoutID

func (r *Repository) CheckoutID() string

func (*Repository) CheckoutRoot

func (r *Repository) CheckoutRoot() string

func (*Repository) Commit

func (r *Repository) Commit(ctx context.Context, message string, expected Fingerprint) (CommitResult, error)

func (*Repository) DraftContext

func (r *Repository) DraftContext(ctx context.Context, expected Fingerprint) (string, error)

DraftContext returns only finalized staged changes and recent subjects.

func (*Repository) Inspect

func (r *Repository) Inspect(ctx context.Context) (RepositoryState, error)

func (*Repository) ScopeContext

func (r *Repository) ScopeContext(ctx context.Context, expected Fingerprint, statusToken string) (string, error)

ScopeContext returns bounded, read-only context for whole-file scope planning. The caller must still revalidate the status token before applying a proposal.

func (*Repository) SetCoordinator

func (r *Repository) SetCoordinator(c MutationCoordinator)

func (*Repository) Stage

func (r *Repository) Stage(ctx context.Context, request StageRequest, expected Fingerprint) (RepositoryState, error)

type RepositoryState

type RepositoryState struct {
	CheckoutRoot               string         `json:"-"`
	GitDirID                   string         `json:"git_dir_id"`
	Branch                     string         `json:"branch,omitempty"`
	Detached                   bool           `json:"detached"`
	Unborn                     bool           `json:"unborn"`
	HeadOID                    string         `json:"head_oid,omitempty"`
	Operation                  OperationState `json:"operation"`
	Staged                     []Change       `json:"staged"`
	Unstaged                   []Change       `json:"unstaged"`
	Untracked                  []Change       `json:"untracked"`
	Conflicted                 []Change       `json:"conflicted"`
	Summary                    DiffSummary    `json:"summary"`
	Fingerprint                Fingerprint    `json:"fingerprint"`
	StatusToken                string         `json:"status_token,omitempty"`
	SelectionAvailable         bool           `json:"selection_available"`
	SelectionUnavailableReason string         `json:"selection_unavailable_reason,omitempty"`
	Truncated                  bool           `json:"truncated"`
	TotalStaged                int            `json:"total_staged"`
	TotalUnstaged              int            `json:"total_unstaged"`
	TotalUntracked             int            `json:"total_untracked"`
}

type StageMode

type StageMode string
const (
	StageAll            StageMode = "all"
	StageExactSelection StageMode = "exact_selection"
)

type StageRequest

type StageRequest struct {
	Mode        StageMode `json:"mode"`
	Paths       []string  `json:"paths,omitempty"`
	StatusToken string    `json:"status_token,omitempty"`
}

Jump to

Keyboard shortcuts

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