preserve

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSourceWorktree = errors.New("no source worktree found")

ErrNoSourceWorktree is returned when no suitable source worktree is found for file preservation. This is a benign condition (e.g., first worktree).

Functions

func CopyFile

func CopyFile(src, dst string) (bool, error)

CopyFile copies src to dst, creating parent directories as needed. Uses O_CREATE|O_EXCL to skip files that already exist (never overwrite). Preserves the source file's permission bits. Symlinks are skipped. Returns true if the file was copied, false if it was skipped (already exists or symlink).

func FindIgnoredFiles

func FindIgnoredFiles(ctx context.Context, worktreeDir string) ([]string, error)

FindIgnoredFiles returns paths (relative to worktreeDir) of all git-ignored files present in the worktree.

func FindSourceWorktree

func FindSourceWorktree(ctx context.Context, gitDir, targetPath string) (string, error)

FindSourceWorktree finds an existing worktree to copy preserved files from. It prefers the worktree on the default branch, falling back to the first worktree that isn't the target.

func PreserveFiles

func PreserveFiles(ctx context.Context, cfg config.PreserveConfig, sourceDir, targetDir string) ([]string, error)

PreserveFiles copies git-ignored files matching the configured patterns from sourceDir into targetDir. Returns the list of relative paths that were copied. Individual file copy failures are logged and skipped; the returned error only indicates failure to enumerate ignored files.

Types

This section is empty.

Jump to

Keyboard shortcuts

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