git

package
v0.0.0-...-f8a9328 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Committer

type Committer struct{}

Committer handles git staging and committing via go-git.

func (*Committer) CommitFiles

func (c *Committer) CommitFiles(repoPath string, paths []string, message string) (string, error)

CommitFiles stages the given paths and creates a commit. Returns the full hex-encoded commit SHA on success. Paths are relative to the repository root.

type GoGitDetector

type GoGitDetector struct{}

GoGitDetector implements RepoStateDetector using go-git.

func (*GoGitDetector) Detect

func (d *GoGitDetector) Detect(vaultPath string) (RepoState, error)

Detect reads the git repository state at vaultPath. Returns RepoState{RepoDetected: false} if no repo is found (not an error).

type OperationType

type OperationType int

OperationType classifies the caller's intended action.

const (
	OpRead        OperationType = iota // query commands
	OpDryRun                           // --dry-run / --diff
	OpWrite                            // apply mutation to disk
	OpWriteCommit                      // apply + git commit
)

func (OperationType) String

func (o OperationType) String() string

type PolicyChecker

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

PolicyChecker evaluates the git policy matrix.

func NewPolicyChecker

func NewPolicyChecker(cfg vault.GitPolicyConfig) (*PolicyChecker, error)

NewPolicyChecker creates a PolicyChecker from config. Returns error if config contains invalid policy values or unknown rule names.

func (*PolicyChecker) Check

func (pc *PolicyChecker) Check(state RepoState, op OperationType, targetPath string) PolicyResult

Check evaluates all policy rules for the given state and operation. targetPath identifies the file being mutated (empty for read-only operations).

type PolicyDecision

type PolicyDecision int

PolicyDecision is the outcome of a policy rule evaluation.

const (
	Allow PolicyDecision = iota
	Warn
	Refuse
)

func ParsePolicyDecision

func ParsePolicyDecision(s string) (PolicyDecision, error)

ParsePolicyDecision parses a string into a PolicyDecision.

func (PolicyDecision) String

func (d PolicyDecision) String() string

type PolicyReason

type PolicyReason struct {
	Rule    string // stable identifier: "dirty_target", "detached_head", etc.
	Message string
}

PolicyReason describes one triggered policy rule.

type PolicyResult

type PolicyResult struct {
	Decision PolicyDecision
	Reasons  []PolicyReason
}

PolicyResult is the aggregate outcome of a policy check.

type RepoState

type RepoState struct {
	RepoDetected     bool
	Branch           string
	Detached         bool
	MergeInProgress  bool
	RebaseInProgress bool
	WorkingTreeClean bool
	StagedFiles      []string
	UnstagedFiles    []string
	UntrackedFiles   []string
}

RepoState captures git repository state at a point in time.

type RepoStateDetector

type RepoStateDetector interface {
	Detect(vaultPath string) (RepoState, error)
}

RepoStateDetector abstracts git state detection for dependency injection.

Jump to

Keyboard shortcuts

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