Documentation
¶
Index ¶
- Variables
- func CopyFile(src, dst string) (bool, error)
- func FindIgnoredFiles(ctx context.Context, worktreeDir string) ([]string, error)
- func FindSourceWorktree(ctx context.Context, gitDir, targetPath string) (string, error)
- func PreserveFiles(ctx context.Context, cfg config.PreserveConfig, sourceDir, targetDir string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
FindIgnoredFiles returns paths (relative to worktreeDir) of all git-ignored files present in the worktree.
func FindSourceWorktree ¶
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.