gitcrypt

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package gitcrypt provides git-crypt functionality as a hook for worktree operations.

Package gitcrypt provides git-crypt functionality as a hook for worktree operations.

Package gitcrypt provides git-crypt functionality as a hook for worktree operations.

Package gitcrypt provides git-crypt functionality as a hook for worktree operations.

Package gitcrypt provides git-crypt functionality as a hook for worktree operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyFileNotFound indicates that the git-crypt key file was not found.
	ErrKeyFileNotFound = errors.New("git-crypt key file not found")

	// ErrKeyFileInvalid indicates that the git-crypt key file is invalid or corrupted.
	ErrKeyFileInvalid = errors.New("git-crypt key file is invalid or corrupted")

	// ErrRepositoryPathNotFound indicates that the repository path was not found in the hook context.
	ErrRepositoryPathNotFound = errors.New("repository path not found in hook context")

	// ErrWorktreePathNotFound indicates that the worktree path was not found in the hook context.
	ErrWorktreePathNotFound = errors.New("worktree path not found in hook context")

	// ErrBranchNotFound indicates that the branch was not found in the hook context.
	ErrBranchNotFound = errors.New("branch not found in hook context")
)

Git-crypt specific errors.

Functions

This section is empty.

Types

type Detector

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

Detector handles detection of git-crypt usage in repositories.

func NewDetector

func NewDetector(fs fs.FS) *Detector

NewDetector creates a new GitCryptDetector instance.

func (*Detector) DetectGitCryptUsage

func (d *Detector) DetectGitCryptUsage(repoPath string) (bool, error)

DetectGitCryptUsage checks if the repository uses git-crypt by examining .gitattributes.

type KeyManager

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

KeyManager handles git-crypt key location and validation.

func NewKeyManager

func NewKeyManager(fs fs.FS, git git.Git, prompt prompt.Prompter) *KeyManager

NewKeyManager creates a new GitCryptKeyManager instance.

func (*KeyManager) FindGitCryptKey

func (k *KeyManager) FindGitCryptKey(repoPath string) (string, error)

FindGitCryptKey looks for git-crypt key in the repository.

func (*KeyManager) PromptUserForKeyPath

func (k *KeyManager) PromptUserForKeyPath() (string, error)

PromptUserForKeyPath prompts the user for the git-crypt key file path.

func (*KeyManager) ValidateKeyFile

func (k *KeyManager) ValidateKeyFile(keyPath string) error

ValidateKeyFile validates that the provided key file exists and is readable.

type WorktreeCheckoutHook

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

WorktreeCheckoutHook provides git-crypt functionality as a worktree checkout hook.

func NewWorktreeCheckoutHook

func NewWorktreeCheckoutHook() *WorktreeCheckoutHook

NewWorktreeCheckoutHook creates a new GitCryptWorktreeCheckoutHook instance.

func (*WorktreeCheckoutHook) Execute

Execute is a no-op for GitCryptWorktreeCheckoutHook.

func (*WorktreeCheckoutHook) Name

func (h *WorktreeCheckoutHook) Name() string

Name returns the hook name.

func (*WorktreeCheckoutHook) OnWorktreeCheckout

func (h *WorktreeCheckoutHook) OnWorktreeCheckout(ctx *hooks.HookContext) error

OnWorktreeCheckout handles git-crypt setup before worktree checkout.

func (*WorktreeCheckoutHook) Priority

func (h *WorktreeCheckoutHook) Priority() int

Priority returns the hook priority.

func (*WorktreeCheckoutHook) RegisterForOperations

func (h *WorktreeCheckoutHook) RegisterForOperations(
	registerHook func(operation string, hook hooks.WorktreeCheckoutHook) error,
) error

RegisterForOperations registers this hook for worktree operations.

type WorktreeSetup

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

WorktreeSetup handles git-crypt setup in worktree directories.

func NewWorktreeSetup

func NewWorktreeSetup(fs fs.FS) *WorktreeSetup

NewWorktreeSetup creates a new GitCryptWorktreeSetup instance.

func (*WorktreeSetup) SetupGitCryptForWorktree

func (s *WorktreeSetup) SetupGitCryptForWorktree(repoPath, worktreePath, keyPath string) error

SetupGitCryptForWorktree sets up git-crypt in the worktree by copying the key.

Jump to

Keyboard shortcuts

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