Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 859b427

Browse files
committed
Check if the vendor/ directory is usable, even after a successful build
1 parent 8f6b25e commit 859b427

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,17 @@ func main() {
393393
tryBuild("build", "./build") ||
394394
tryBuild("build.sh", "./build.sh")
395395

396-
if !buildSucceeded {
397-
if modMode == ModVendor {
398-
// test if running `go` with -mod=vendor works, and if it doesn't, try to fallback to -mod=mod
399-
// or not set if the go version < 1.14.
400-
if !checkVendor() {
401-
modMode = modModIfSupported()
402-
log.Println("The vendor directory is not consistent with the go.mod; not using vendored dependencies.")
403-
}
396+
if modMode == ModVendor {
397+
// test if running `go` with -mod=vendor works, and if it doesn't, try to fallback to -mod=mod
398+
// or not set if the go version < 1.14. Note we check this post-build in case the build brings
399+
// the vendor directory up to date.
400+
if !checkVendor() {
401+
modMode = modModIfSupported()
402+
log.Println("The vendor directory is not consistent with the go.mod; not using vendored dependencies.")
404403
}
404+
}
405405

406+
if !buildSucceeded {
406407
if modMode == ModVendor {
407408
log.Printf("Skipping dependency installation because a Go vendor directory was found.")
408409
} else {

0 commit comments

Comments
 (0)