File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -193,10 +193,20 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
193
193
log .Println ("Starting to extract packages." )
194
194
195
195
sep := regexp .QuoteMeta (string (filepath .Separator ))
196
- // if a path matches this regexp, we don't want to extract this package. Currently, it checks
197
- // - that the path does not contain a `..` segment, and
198
- // - the path does not contain a `vendor` directory.
199
- noExtractRe := regexp .MustCompile (`.*(^|` + sep + `)(\.\.|vendor)($|` + sep + `).*` )
196
+
197
+ // Construct a list of directory segments to exclude from extraction, starting with ".."
198
+ excludedDirs := []string {`\.\.` }
199
+
200
+ // If CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS is "true", we extract `vendor` directories;
201
+ // otherwise (the default) is to exclude them from extraction
202
+ includeVendor := os .Getenv ("CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS" ) == "true"
203
+ if ! includeVendor {
204
+ excludedDirs = append (excludedDirs , "vendor" )
205
+ }
206
+
207
+ // If a path matches this regexp, we don't extract this package. It checks whether the path
208
+ // contains one of the `excludedDirs`.
209
+ noExtractRe := regexp .MustCompile (`.*(^|` + sep + `)(` + strings .Join (excludedDirs , "|" ) + `)($|` + sep + `).*` )
200
210
201
211
// extract AST information for all packages
202
212
packages .Visit (pkgs , nil , func (pkg * packages.Package ) {
You can’t perform that action at this time.
0 commit comments