git

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package git wraps go-git to push, pull, and inspect the vault repository.

Index

Constants

This section is empty.

Variables

View Source
var ErrMergeConflict = errors.New("merge conflict")

ErrMergeConflict is returned by MergeOrigin when the merge produces unresolved conflicts. Inspect the working tree, call resolveSecretsConflict, then ContinueMerge — or AbortMerge to restore the pre-merge state.

View Source
var ErrNothingToCommit = errors.New("nothing to commit")

ErrNothingToCommit is returned by CommitVault when .envault/ has no staged changes — the vault is already in sync with the last commit.

Functions

func AbortMerge

func AbortMerge(repoRoot string) error

AbortMerge aborts an in-progress merge and restores the pre-merge state.

func CleanVault

func CleanVault(repoRoot string) error

CleanVault removes untracked files under .envault/ so a fast-forward merge is not blocked by "untracked working tree files would be overwritten". Files already committed to git are left untouched.

func CommitVault

func CommitVault(repoRoot string) (string, error)

CommitVault stages all .envault/ files and creates a commit with the canonical message "envault: sync encrypted secrets". It returns the short (7-char) commit hash. If there are no changes it returns ErrNothingToCommit so the caller can still push unpushed commits.

func ConflictStage

func ConflictStage(repoRoot string, stage int, path string) ([]byte, error)

ConflictStage returns the raw bytes of path at the given merge stage. stage 1 = common ancestor (base), 2 = ours, 3 = theirs. Returns nil bytes (and nil error) when the file did not exist at that stage.

func ConflictedFiles

func ConflictedFiles(repoRoot string) ([]string, error)

ConflictedFiles returns the repo-root-relative paths of all files that have unresolved merge conflicts (i.e., appear as "UU" in the index).

func ContinueMerge

func ContinueMerge(repoRoot string) error

ContinueMerge commits the in-progress merge using the auto-generated message.

func CurrentBranch

func CurrentBranch(repoRoot string) (string, error)

CurrentBranch returns the name of the currently checked-out branch.

func DetectOrigin

func DetectOrigin(repoRoot string) (string, error)

DetectOrigin reads the URL of the "origin" remote by parsing .git/config inside repoRoot directly — no git binary required. Returns an empty string when the file is absent or no origin is configured.

func FetchOrigin

func FetchOrigin(repoRoot string) error

FetchOrigin fetches from the origin remote.

func HeadHash

func HeadHash(repoRoot string) (string, error)

HeadHash returns the short hash of the current HEAD commit.

func IsVaultTracked

func IsVaultTracked(repoRoot string) bool

IsVaultTracked reports whether .envault/config is known to git (i.e., the vault was cloned from a remote rather than only created locally). When this returns false the vault files are untracked and were never committed.

func MergeOrigin

func MergeOrigin(repoRoot string) error

MergeOrigin merges origin/<current-branch> into HEAD. Fast-forwards when possible; creates a merge commit for diverged histories. Returns ErrMergeConflict when the merge leaves unresolved conflicts so the caller can apply application-level resolution before calling ContinueMerge or AbortMerge.

func PushOrigin

func PushOrigin(repoRoot string) error

PushOrigin pushes HEAD to the origin remote.

func StageFile

func StageFile(repoRoot, path string) error

StageFile runs `git add <path>` inside repoRoot, marking the file as resolved.

Types

This section is empty.

Jump to

Keyboard shortcuts

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