Skip to content

Commit

Permalink
refactor: inline
Browse files Browse the repository at this point in the history
  • Loading branch information
alexplischke committed Jul 15, 2024
1 parent f609519 commit 5365383
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions internal/sauceignore/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ func NewPattern(p string) Pattern {
return Pattern{P: p}
}

func convPtrnsToGitignorePtrns(pp []Pattern) []gitignore.Pattern {
res := make([]gitignore.Pattern, len(pp))
for i := 0; i < len(pp); i++ {
res[i] = gitignore.ParsePattern(pp[i].P, nil)
}

return res
}

// Matcher defines matcher for sauceignore patterns.
type Matcher interface {
Match(path []string, isDir bool) bool
Expand All @@ -75,9 +66,13 @@ func (m *matcher) Match(path []string, isDir bool) bool {
}

// NewMatcher constructs a new matcher.
func NewMatcher(ps []Pattern) Matcher {
gps := convPtrnsToGitignorePtrns(ps)
return &matcher{matcher: gitignore.NewMatcher(gps)}
func NewMatcher(patterns []Pattern) Matcher {
pp := make([]gitignore.Pattern, len(patterns))
for i, p := range patterns {
pp[i] = gitignore.ParsePattern(p.P, nil)
}

return &matcher{matcher: gitignore.NewMatcher(pp)}
}

// NewMatcherFromFile constructs a new matcher from file.
Expand Down

0 comments on commit 5365383

Please sign in to comment.