Skip to content

Commit

Permalink
Log when vendor dir extraction is active
Browse files Browse the repository at this point in the history
  • Loading branch information
smowton committed Sep 30, 2024
1 parent 684aedf commit c9d6c80
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions go/extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,23 @@ func ExtractWithFlags(buildFlags []string, patterns []string, extractTests bool)
}
}

testMessage := ""
// If CODEQL_EXTRACTOR_GO_[OPTION_]EXTRACT_VENDOR_DIRS is "true", we extract `vendor` directories;
// otherwise (the default) is to exclude them from extraction
includeVendor := util.IsVendorDirExtractionEnabled()

modeNotifications := make([]string, 0, 2)
if extractTests {
testMessage = " (test extraction enabled)"
modeNotifications = append(modeNotifications, "test extraction enabled")
}
if includeVendor {
modeNotifications = append(modeNotifications, "extracting vendor directories")
}
log.Printf("Running packages.Load%s.", testMessage)

modeMessage := strings.Join(modeNotifications, ", ")
if modeMessage != "" {
modeMessage = " (" + modeMessage + ")"
}
log.Printf("Running packages.Load%s.", modeMessage)

// This includes test packages if either we're tracing a `go test` command,
// or if CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_TESTS is set to "true".
Expand Down Expand Up @@ -233,9 +245,6 @@ func ExtractWithFlags(buildFlags []string, patterns []string, extractTests bool)
// Construct a list of directory segments to exclude from extraction, starting with ".."
excludedDirs := []string{`\.\.`}

// If CODEQL_EXTRACTOR_GO_[OPTION_]EXTRACT_VENDOR_DIRS is "true", we extract `vendor` directories;
// otherwise (the default) is to exclude them from extraction
includeVendor := util.IsVendorDirExtractionEnabled()
if !includeVendor {
excludedDirs = append(excludedDirs, "vendor")
}
Expand Down

0 comments on commit c9d6c80

Please sign in to comment.