Skip to content

Commit

Permalink
#60: Strategies bleeding to extra dirs/files
Browse files Browse the repository at this point in the history
  • Loading branch information
iignatevich committed Jan 15, 2025
1 parent f12dcb7 commit de9351f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions compose/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,24 @@ var (
StrategyFilterPackage = "filter-package-files"
)

// return conflict const (0 - no warning, 1 - conflict with local, 2 conflict with pacakge)
// return conflict const (0 - no warning, 1 - conflict with local, 2 conflict with package)

func cleanStrategyPaths(paths []string) []string {
// remove trailing separators and add only one separator at the end.
// so prefix won't be greedy during comparison.
var r []string

for _, p := range paths {
path := filepath.Clean(p)
if !strings.HasSuffix(path, string(os.PathSeparator)) {
path += string(os.PathSeparator)
}

r = append(r, path)
}

return r
}

func retrieveStrategies(packages []*Package) ([]*mergeStrategy, map[string][]*mergeStrategy) {
var ls []*mergeStrategy
Expand All @@ -70,7 +87,7 @@ func retrieveStrategies(packages []*Package) ([]*mergeStrategy, map[string][]*me
if s == undefinedStrategy {
continue
}
strategy := &mergeStrategy{s, t, item.Paths}
strategy := &mergeStrategy{s, t, cleanStrategyPaths(item.Paths)}

if t == localStrategy {
ls = append(ls, strategy)
Expand Down

0 comments on commit de9351f

Please sign in to comment.