file_patch_apply

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package file_patch_apply implements the file_patch_apply action handler.

The file_patch_apply action applies unified diff patches to files with support for: - Inline patch content or external patch files - Context line validation - Strict mode (fail on any hunk failure) - Atomic writes (temp file + rename) - Backup creation before modification - Idempotency (no change if patch already applied)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct{}

Handler implements the Handler interface for file_patch_apply actions.

func (*Handler) DryRun

func (h *Handler) DryRun(ctx actions.Context, step *config.Step) error

DryRun logs what would happen without making changes.

func (*Handler) Execute

func (h *Handler) Execute(ctx actions.Context, step *config.Step) (actions.Result, error)

Execute runs the file_patch_apply action.

func (*Handler) Metadata

func (h *Handler) Metadata() actions.ActionMetadata

Metadata returns metadata about the file_patch_apply action.

func (*Handler) Run

func (h *Handler) Run(ctx actions.Context, step *config.Step) (actions.Result, error)

Run is the Spec 16 unified entry point. Applies the patch in memory to predict the result; plan mode reports the prediction, execute mode commits the atomic write.

func (*Handler) Validate

func (h *Handler) Validate(step *config.Step) error

Validate checks if the file_patch_apply configuration is valid.

type Hunk

type Hunk struct {
	OldStart int      // Starting line in old file
	OldCount int      // Number of lines in old file
	NewStart int      // Starting line in new file
	NewCount int      // Number of lines in new file
	Lines    []string // Patch lines (with +, -, or space prefix)
}

Hunk represents a single hunk in a unified diff

type Patch

type Patch struct {
	Hunks []*Hunk
}

Patch represents a parsed unified diff patch

Jump to

Keyboard shortcuts

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