Skip to content

Commit 19a68dd

Browse files
authored
Merge pull request #46 from gitpod-io/fo/filter-variants
Filter variant chunks
2 parents a4734c0 + c8255bf commit 19a68dd

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

pkg/dazzle/project.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ func LoadFromDir(contextBase string, opts LoadFromDirOpts) (*Project, error) {
197197

198198
res.Chunks = make([]ProjectChunk, 0, len(chds))
199199
for _, chd := range chds {
200-
if cfg.chunkIgnores != nil && cfg.chunkIgnores.MatchesPath(chd.Name()) {
201-
continue
202-
}
203200
if strings.HasPrefix(chd.Name(), "_") || strings.HasPrefix(chd.Name(), ".") {
204201
continue
205202
}
@@ -210,12 +207,29 @@ func LoadFromDir(contextBase string, opts LoadFromDirOpts) (*Project, error) {
210207
if err != nil {
211208
return nil, err
212209
}
213-
res.Chunks = append(res.Chunks, chnk...)
210+
211+
res.Chunks = append(res.Chunks, filterChunks(chnk, cfg.chunkIgnores)...)
214212
}
215213

216214
return res, nil
217215
}
218216

217+
func filterChunks(chunks []ProjectChunk, ignores *ignore.GitIgnore) []ProjectChunk {
218+
if ignores == nil {
219+
return chunks
220+
}
221+
222+
filtered := make([]ProjectChunk, 0)
223+
for _, chunk := range chunks {
224+
if ignores.MatchesPath(chunk.Name) {
225+
continue
226+
}
227+
filtered = append(filtered, chunk)
228+
}
229+
230+
return filtered
231+
}
232+
219233
func resolveCombinations(ipt []ChunkCombination) ([]ChunkCombination, error) {
220234
type Comb struct {
221235
Chunks map[string]struct{}

0 commit comments

Comments
 (0)