"Fix" isolate commands fucking each other (hallucinate)
This commit is contained in:
32
main.go
32
main.go
@@ -642,11 +642,13 @@ func RunIsolateCommands(association utils.FileCommandAssociation, file string, f
|
||||
runIsolateCommandsLogger.Trace("File data before isolate modifications: %s", utils.LimitString(fileDataStr, 200))
|
||||
|
||||
anythingDone := false
|
||||
currentFileData := fileDataStr
|
||||
|
||||
for _, isolateCommand := range association.IsolateCommands {
|
||||
// Check if this isolate command should use JSON mode
|
||||
if isolateCommand.JSON || *utils.JSON {
|
||||
runIsolateCommandsLogger.Debug("Begin processing file with JSON isolate command %q", isolateCommand.Name)
|
||||
modifications, err := processor.ProcessJSON(fileDataStr, isolateCommand, file)
|
||||
modifications, err := processor.ProcessJSON(currentFileData, isolateCommand, file)
|
||||
if err != nil {
|
||||
runIsolateCommandsLogger.Error("Failed to process file with JSON isolate command %q: %v", isolateCommand.Name, err)
|
||||
continue
|
||||
@@ -661,15 +663,21 @@ func RunIsolateCommands(association utils.FileCommandAssociation, file string, f
|
||||
runIsolateCommandsLogger.Debug("Executing %d JSON isolate modifications for file", len(modifications))
|
||||
runIsolateCommandsLogger.Trace("JSON isolate modifications: %v", modifications)
|
||||
var count int
|
||||
fileDataStr, count = utils.ExecuteModifications(modifications, fileDataStr)
|
||||
runIsolateCommandsLogger.Trace("File data after JSON isolate modifications: %s", utils.LimitString(fileDataStr, 200))
|
||||
currentFileData, count = utils.ExecuteModifications(modifications, currentFileData)
|
||||
runIsolateCommandsLogger.Trace("File data after JSON isolate modifications: %s", utils.LimitString(currentFileData, 200))
|
||||
|
||||
atomic.AddInt64(&stats.TotalModifications, int64(count))
|
||||
|
||||
cmdCount, ok := stats.ModificationsPerCommand.Load(isolateCommand.Name)
|
||||
if !ok {
|
||||
stats.ModificationsPerCommand.Store(isolateCommand.Name, 0)
|
||||
cmdCount = 0
|
||||
}
|
||||
stats.ModificationsPerCommand.Store(isolateCommand.Name, cmdCount.(int)+len(modifications))
|
||||
|
||||
runIsolateCommandsLogger.Info("Executed %d JSON isolate modifications for file", count)
|
||||
} else {
|
||||
// Regular regex processing for isolate commands
|
||||
runIsolateCommandsLogger.Debug("Begin processing file with isolate command %q", isolateCommand.Regex)
|
||||
patterns := isolateCommand.Regexes
|
||||
if len(patterns) == 0 {
|
||||
patterns = []string{isolateCommand.Regex}
|
||||
@@ -677,7 +685,8 @@ func RunIsolateCommands(association utils.FileCommandAssociation, file string, f
|
||||
for idx, pattern := range patterns {
|
||||
tmpCmd := isolateCommand
|
||||
tmpCmd.Regex = pattern
|
||||
modifications, err := processor.ProcessRegex(fileDataStr, tmpCmd, file)
|
||||
runIsolateCommandsLogger.Debug("Begin processing file with isolate command %q (pattern %d/%d)", isolateCommand.Name, idx+1, len(patterns))
|
||||
modifications, err := processor.ProcessRegex(currentFileData, tmpCmd, file)
|
||||
if err != nil {
|
||||
runIsolateCommandsLogger.Error("Failed to process file with isolate command %q (pattern %d/%d): %v", isolateCommand.Name, idx+1, len(patterns), err)
|
||||
continue
|
||||
@@ -692,11 +701,18 @@ func RunIsolateCommands(association utils.FileCommandAssociation, file string, f
|
||||
runIsolateCommandsLogger.Debug("Executing %d isolate modifications for file", len(modifications))
|
||||
runIsolateCommandsLogger.Trace("Isolate modifications: %v", modifications)
|
||||
var count int
|
||||
fileDataStr, count = utils.ExecuteModifications(modifications, fileDataStr)
|
||||
runIsolateCommandsLogger.Trace("File data after isolate modifications: %s", utils.LimitString(fileDataStr, 200))
|
||||
currentFileData, count = utils.ExecuteModifications(modifications, currentFileData)
|
||||
runIsolateCommandsLogger.Trace("File data after isolate modifications: %s", utils.LimitString(currentFileData, 200))
|
||||
|
||||
atomic.AddInt64(&stats.TotalModifications, int64(count))
|
||||
|
||||
cmdCount, ok := stats.ModificationsPerCommand.Load(isolateCommand.Name)
|
||||
if !ok {
|
||||
stats.ModificationsPerCommand.Store(isolateCommand.Name, 0)
|
||||
cmdCount = 0
|
||||
}
|
||||
stats.ModificationsPerCommand.Store(isolateCommand.Name, cmdCount.(int)+len(modifications))
|
||||
|
||||
runIsolateCommandsLogger.Info("Executed %d isolate modifications for file", count)
|
||||
}
|
||||
}
|
||||
@@ -705,5 +721,5 @@ func RunIsolateCommands(association utils.FileCommandAssociation, file string, f
|
||||
runIsolateCommandsLogger.Debug("No isolate modifications were made for file")
|
||||
return fileDataStr, NothingToDo
|
||||
}
|
||||
return fileDataStr, nil
|
||||
return currentFileData, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user