Compare commits
3 Commits
2b973be0c1
...
v3.6.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 05bc31aa90 | |||
| 81d69b8ce0 | |||
| 679322a8ac |
@@ -33,6 +33,11 @@ func ProcessRegex(content string, command utils.ModifyCommand, filename string)
|
||||
// We don't HAVE to do this multiple times for a pattern
|
||||
// But it's quick enough for us to not care
|
||||
pattern := resolveRegexPlaceholders(command.Regex)
|
||||
// I'm not too happy about having to trim regex, we could have meaningful whitespace or newlines
|
||||
// But it's a compromise that allows us to use | in yaml
|
||||
// Otherwise we would have to escape every god damn pair of quotation marks
|
||||
// And a bunch of other shit
|
||||
pattern = strings.TrimSpace(pattern)
|
||||
logger.Debug("Compiling regex pattern: %s", pattern)
|
||||
|
||||
patternCompileStart := time.Now()
|
||||
|
||||
@@ -75,7 +75,15 @@ func AssociateFilesWithCommands(files []string, commands []ModifyCommand) (map[s
|
||||
}
|
||||
for _, command := range commands {
|
||||
for _, glob := range command.Files {
|
||||
matches, err := Matches(file, glob)
|
||||
_, pattern, err := FigureOutGlobRoot(glob)
|
||||
if err != nil {
|
||||
logger.Trace("Failed to figure out glob root for %s: %v", glob, err)
|
||||
continue
|
||||
}
|
||||
file = filepath.Clean(file)
|
||||
file = strings.ReplaceAll(file, "\\", "/")
|
||||
|
||||
matches, err := Matches(file, pattern)
|
||||
if err != nil {
|
||||
logger.Trace("Failed to match glob %s with file %s: %v", glob, file, err)
|
||||
continue
|
||||
@@ -198,6 +206,9 @@ func ExpandGLobs(patterns map[string]struct{}) ([]string, error) {
|
||||
logger.Debug("Found %d matches for pattern %s", len(matches), pattern)
|
||||
for _, m := range matches {
|
||||
m = filepath.Join(root, m)
|
||||
m = filepath.Clean(m)
|
||||
m = strings.ReplaceAll(m, "\\", "/")
|
||||
|
||||
info, err := os.Stat(m)
|
||||
if err != nil {
|
||||
logger.Warning("Error getting file info for %s: %v", m, err)
|
||||
|
||||
Reference in New Issue
Block a user