Documentation
¶
Overview ¶
Package applypatch 提供 apply_patch 工具:codex `*** Begin Patch` 格式的 解析与应用(多文件 增/改/删/改名,事务性——任一失败全部不落盘)。 格式与匹配算法移植自 openai/codex codex-rs/apply-patch crate (parser.rs / file_update.rs / seek_sequence.rs,Apache-2.0;streaming 与 CLI 部分不移植)。行尾策略取 NormalizeToLf 模式(统一 LF + 保留尾换行; PreserveLineEndings 混合行尾保留留后续)。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Chunk ¶
type Chunk struct {
ChangeContext string // @@ 头文本(定位锚,单行 seek)
OldLines []string
NewLines []string
IsEOF bool // *** End of File 标记:优先在文件尾匹配
}
Chunk 单个改动块(一个 @@ 区段)。OldLines/NewLines 含上下文行; ContextPairs 记录两侧同为上下文的行号对(PreserveLineEndings 模式用, 本模式仅调试展示)。
type Config ¶
Config 构造配置。Root = 工作区根(空 = 拒绝构造,P0 纪律)。ProtectDirs = 写保护区顶层子目录名——补丁任一目标(含 Move to 改名目标)命中即整单 拒绝(判定在 Apply 前,事务性自然成立);nil/空 = 不设区零变化。
type FileOp ¶
type FileOp struct {
Kind Kind
Path string
MoveTo string // Update 可选改名
Chunks []Chunk // Update
Contents []string // Add(+ 行内容)
}
FileOp 单文件操作。
Click to show internal directories.
Click to hide internal directories.