Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeFileID ¶
ComputeFileID returns a deterministic short ID (12 hex chars) for a file path. This is the default ID for a file when no embedded ID exists. CRITICAL: Path is normalized to forward slashes to ensure consistent IDs across Windows/Linux/macOS.
The ID is the first 6 bytes (12 hex chars) of SHA1(path), providing: - 48 bits of entropy (~0.00000001% collision probability at 10k files) - Readable format in file headers: @generated-id: a1b2c3d4e5f6 - Deterministic: same path always produces same ID (no lockfile churn)
Types ¶
type MergeProgress ¶
type MergeProgress struct {
ConflictFile string // Set when a file conflict is detected
PushError error // Set when pushing to remote fails (soft failure)
}
MergeProgress contains merge-specific progress information (conflicts, errors).
type ProgressCallback ¶
type ProgressCallback func(stepID string, merge *MergeProgress)
ProgressCallback is the function type for reporting merge progress. This matches the signature used by the generator's OnProgressUpdate.
type Subsystem ¶
type Subsystem struct {
Enabled *config.PersistentEditsEnabled
// OnProgress is called to report merge phases and events.
// Injected by the Generator to enable progress reporting.
OnProgress ProgressCallback
// contains filtered or unexported fields
}
Subsystem handles 3-way merge with persistent edits
func NewSubsystem ¶
func NewSubsystem( cfg *configuration.Config, fs filesystem.FileSystem, git merge.Git, lockFile *config.LockFile, fileTracker *filetracking.Tracker, outDir string, enabled *config.PersistentEditsEnabled, ) *Subsystem
NewSubsystem creates a new patches subsystem with the given configuration.
func (*Subsystem) GetActualPath ¶
GetActualPath returns the actual path for a file, accounting for user moves. If the user moved a file from path A to path B, and we're trying to write to A, this returns B so we respect the user's file organization.
func (*Subsystem) GetOrCreateID ¶
GetOrCreateID returns the ID for a file path. If the file already has an embedded ID (from scanning), use that for stability. Otherwise, compute a deterministic ID from the path using SHA1. This means: - New files get deterministic IDs (no storage needed, no churn) - Files with embedded IDs keep those IDs (enables move detection) - Supports both legacy UUIDs and new short IDs (12 hex chars)
The path parameter may be absolute or relative. For lookup, we convert to outDir-relative (matching ScanForGeneratedIDs output). For computation, we use repo-relative paths to ensure unique IDs across targets.
func (*Subsystem) IsEnabled ¶
IsEnabled returns true if persistent edits are explicitly enabled ("true")
func (*Subsystem) IsNever ¶
IsNever returns true if persistent edits are explicitly disabled ("never")
func (*Subsystem) PerformMerge ¶
func (p *Subsystem) PerformMerge(ctx context.Context, virtualFiles map[string]*merge.VirtualFile) (bool, error)
PerformMerge performs the complete 3-way merge, commit, push, and lockfile update. Progress is reported via the logger's step tracking system. Returns (isNoOp, error) where isNoOp is true if no changes were needed. Returns merge.ConflictsError if merge conflicts are detected (files are still written with conflict markers).
When called within a WithStepCtx block, substeps will influence the parent's outcome: if all substeps skip, the parent step will also skip.