Skip to content

Commit

Permalink
Merge pull request #46 from gitpod-io/fo/filter-variants
Browse files Browse the repository at this point in the history
Filter variant chunks
  • Loading branch information
kylos101 authored Mar 9, 2022
2 parents a4734c0 + c8255bf commit 19a68dd
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pkg/dazzle/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@ func LoadFromDir(contextBase string, opts LoadFromDirOpts) (*Project, error) {

res.Chunks = make([]ProjectChunk, 0, len(chds))
for _, chd := range chds {
if cfg.chunkIgnores != nil && cfg.chunkIgnores.MatchesPath(chd.Name()) {
continue
}
if strings.HasPrefix(chd.Name(), "_") || strings.HasPrefix(chd.Name(), ".") {
continue
}
Expand All @@ -210,12 +207,29 @@ func LoadFromDir(contextBase string, opts LoadFromDirOpts) (*Project, error) {
if err != nil {
return nil, err
}
res.Chunks = append(res.Chunks, chnk...)

res.Chunks = append(res.Chunks, filterChunks(chnk, cfg.chunkIgnores)...)
}

return res, nil
}

func filterChunks(chunks []ProjectChunk, ignores *ignore.GitIgnore) []ProjectChunk {
if ignores == nil {
return chunks
}

filtered := make([]ProjectChunk, 0)
for _, chunk := range chunks {
if ignores.MatchesPath(chunk.Name) {
continue
}
filtered = append(filtered, chunk)
}

return filtered
}

func resolveCombinations(ipt []ChunkCombination) ([]ChunkCombination, error) {
type Comb struct {
Chunks map[string]struct{}
Expand Down

0 comments on commit 19a68dd

Please sign in to comment.