Documentation
¶
Index ¶
- Constants
- Variables
- type Action
- type AddFile
- type ApplyInput
- type ApplyOutput
- type Change
- type DeleteFile
- type DiffInput
- type DiffOutput
- type DiffResult
- type DiffStats
- type EmptyInput
- type EmptyOutput
- type Hunk
- type Service
- type Session
- func (s *Session) Add(ctx context.Context, path string, data []byte) error
- func (s *Session) ApplyPatch(ctx context.Context, patchText string, directory ...string) error
- func (s *Session) Commit(ctx ...context.Context) error
- func (s *Session) Delete(ctx context.Context, path string) error
- func (s *Session) Move(ctx context.Context, src, dst string) error
- func (s *Session) Rollback(ctx ...context.Context) error
- func (s *Session) Snapshot(ctx context.Context) ([]Change, error)
- func (s *Session) Update(ctx context.Context, path string, newData []byte) error
- type SnapshotOutput
- type UpdateChunk
- type UpdateFile
Constants ¶
const Name = "system/patch"
Name of the system/patch action service.
Variables ¶
var ErrNoChange = errors.New("no change between old and new")
Functions ¶
This section is empty.
Types ¶
type ApplyInput ¶
type ApplyInput struct {
// The service applies the patch relative to the current working directory of the Fluxor runtime.
Patch string `json:"patch" description:"Patch text to apply (either unified-diff format or simplified patch format)"`
// Directory is the base directory for resolving relative paths in the patch.
// If not provided, paths are resolved relative to the current working directory.
Workdir string `json:"workdir" required:"true" description:"Workdir to relative paths in the patch"`
}
ApplyInput is the payload for Service.apply
type ApplyOutput ¶
type ApplyOutput struct {
Stats DiffStats `json:"stats,omitempty"`
Status string `json:"status,omitempty"`
Error string `json:"error,omitempty"`
}
ApplyOutput summarises the changes applied.
type Change ¶ added in v0.4.1
type Change struct {
Kind string `json:"kind"`
OrigURL string `json:"origUrl,omitempty"`
URL string `json:"url,omitempty"`
Diff string `json:"diff,omitempty"`
}
Change describes a single uncommitted change tracked by the patch session. - kind: one of create|updated|delete - origUrl: original URL (empty for create) - url: current content URL (empty for delete) - diff: unified diff of original vs current content
type DeleteFile ¶ added in v0.1.19
type DeleteFile struct{ Path string }
DeleteFile operation (*** Delete File: path).
type DiffInput ¶
type DiffInput struct {
OldContent string `json:"old" description:"Original file content"`
NewContent string `json:"new" description:"Updated file content"`
Path string `json:"path,omitempty" description:"Display path for diff headers"`
ContextLines int `json:"contextLines,omitempty" description:"Number of context lines to include in diff (default 3)"`
}
DiffInput is the payload for Service.diff
type DiffOutput ¶
type DiffOutput DiffResult
DiffOutput is identical to DiffResult, re-exported for JSON tags.
type DiffResult ¶
type DiffStats ¶
type DiffStats struct {
Added int // number of lines starting with '+' (excluding +++)
Removed int // number of lines starting with '-' (excluding ---)
}
DiffStats captures basic statistics about a unified-diff output.
func GenerateDiff ¶
func GenerateDiff(oldContent, newContent []byte, filePath string, contextLines int) (string, DiffStats, error)
GenerateDiff produces a GNU unified diff between old and new file contents. It returns the diff string along with insertion/deletion statistics. If the two inputs are identical, an empty diff string is returned.
type EmptyOutput ¶
type EmptyOutput struct{}
type Hunk ¶ added in v0.1.19
type Hunk interface {
// contains filtered or unexported methods
}
Hunk represents any high-level patch operation.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service exposes filesystem patching capabilities as a Fluxor action service. It is stateless – every method call operates with its own ephemeral Session.
func (*Service) Method ¶
func (s *Service) Method(name string) (types.Executable, error)
Method maps method names to executable handlers.
func (*Service) Methods ¶
func (s *Service) Methods() types.Signatures
Methods returns service method catalogue.
type Session ¶
func NewSession ¶
func (*Session) ApplyPatch ¶
type SnapshotOutput ¶ added in v0.4.1
type SnapshotOutput struct {
Workdir string `json:"workdir,omitempty"`
Changes []Change `json:"changes,omitempty"`
Status string `json:"status,omitempty"`
Error string `json:"error,omitempty"`
}
SnapshotOutput lists the current uncommitted changes captured by the active session.
type UpdateChunk ¶ added in v0.1.19
type UpdateChunk struct {
ChangeContext string // optional text after @@
OldLines []string // '-' and ' ' lines (without prefix)
NewLines []string // '+' and ' ' lines (without prefix)
IsEOF bool // true when *** End of File terminator is present
}
UpdateChunk represents a contiguous diff chunk inside an UpdateFile hunk.
type UpdateFile ¶ added in v0.1.19
type UpdateFile struct {
Path string
MovePath string
Chunks []UpdateChunk
}
UpdateFile operation (*** Update File: path).