added replace-all patch type

This commit is contained in:
partisan 2025-05-09 18:27:16 +02:00
parent bb7da3e154
commit 3d08b492ac
5 changed files with 134 additions and 25 deletions

View file

@ -155,7 +155,7 @@ func applyPatch(patchPath, rootPath string) error {
return fmt.Errorf("patch file must specify output (o:) file")
}
if patchType != "new" && patchType != "copy" {
if patchType != "new" && patchType != "copy" && inputFilePath != outputFilePath {
err = os.Rename(inputFilePath, outputFilePath)
if err != nil {
return fmt.Errorf("failed to replace output file: %v", err)
@ -174,6 +174,8 @@ func applyPatch(patchPath, rootPath string) error {
return applyCopyPatch(inputFilePath, outputFilePath)
case "marker":
return applyMarkerPatch(outputFilePath, modifications)
case "replace-all":
return applyReplaceAllPatch(rootPath, modifications)
default:
fmt.Printf("Type not specified defaulting to standard")
return applyStandardModifications(outputFilePath, modifications)