MCPcopy Index your code
hub / github.com/devspace-sh/devspace / CompilePaths

Function CompilePaths

helper/server/ignoreparser/ignoreparser.go:59–96  ·  view source on GitHub ↗

CompilePaths creates a new ignore parser from a string array

(excludePaths []string, log log.Logger)

Source from the content-addressed store, hash-verified

57
58// CompilePaths creates a new ignore parser from a string array
59func CompilePaths(excludePaths []string, log log.Logger) (IgnoreParser, error) {
60 if len(excludePaths) > 0 {
61 requireFullScan := false
62 absoluteNegatePatterns := []string{}
63 for _, line := range excludePaths {
64 line = strings.Trim(line, " ")
65 if line == "" {
66 continue
67 } else if line[0] == '!' {
68 if len(line) > 1 && line[1] == '/' {
69 p := line[1:]
70 if !strings.Contains(p, "**") && !strings.Contains(path.Dir(p), "*") {
71 absoluteNegatePatterns = append(absoluteNegatePatterns, p)
72 } else {
73 log.Warnf("Exclude path '%s' uses a ** or * and thus requires a full initial scan. Please consider using a path in the form of '!/path/to/my/folder/' instead to improve performance", line)
74 requireFullScan = true
75 }
76 } else {
77 log.Warnf("Exclude path '%s' is not scoped to the directory base and thus requires a full initial scan. Please consider using a path in the form of '!/path/to/my/folder/' instead to improve performance", line)
78 requireFullScan = true
79 }
80 }
81 }
82
83 gitIgnoreParser, err := gitignore.CompileIgnoreLines(excludePaths...)
84 if err != nil {
85 return nil, errors.Wrap(err, "compile ignore lines")
86 }
87
88 return &ignoreParser{
89 ignoreParser: gitIgnoreParser,
90 absoluteNegatePatterns: absoluteNegatePatterns,
91 requireFullScan: requireFullScan,
92 }, nil
93 }
94
95 return nil, nil
96}

Callers 7

NewFunction · 0.92
initIgnoreParsersMethod · 0.92
newUpstreamFunction · 0.92
newDownstreamFunction · 0.92
writeTarFunction · 0.92
StartUpstreamServerFunction · 0.92
StartDownstreamServerFunction · 0.92

Calls 1

WarnfMethod · 0.45

Tested by

no test coverage detected