Skip to content

Commit b45c0ff

Browse files
committed
Factor out buildWithoutCustomCommands
1 parent b76e655 commit b45c0ff

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,25 @@ func moveToTemporaryGopath(srcdir string, importpath string) {
454454
log.Printf("GOPATH set to %s.\n", newGopath)
455455
}
456456

457+
func buildWithoutCustomCommands(modMode ModMode) bool {
458+
shouldInstallDependencies := false
459+
// try to build the project
460+
buildSucceeded := autobuilder.Autobuild()
461+
462+
// Build failed or there are still dependency errors; we'll try to install dependencies
463+
// ourselves
464+
if !buildSucceeded {
465+
log.Println("Build failed, continuing to install dependencies.")
466+
467+
shouldInstallDependencies = true
468+
} else if util.DepErrors("./...", modMode.argsForGoVersion(getEnvGoSemVer())...) {
469+
log.Println("Dependencies are still not resolving after the build, continuing to install dependencies.")
470+
471+
shouldInstallDependencies = true
472+
}
473+
return shouldInstallDependencies
474+
}
475+
457476
func main() {
458477
if len(os.Args) > 1 {
459478
usage()
@@ -511,20 +530,7 @@ func main() {
511530
inst := util.Getenv("CODEQL_EXTRACTOR_GO_BUILD_COMMAND", "LGTM_INDEX_BUILD_COMMAND")
512531
shouldInstallDependencies := false
513532
if inst == "" {
514-
// try to build the project
515-
buildSucceeded := autobuilder.Autobuild()
516-
517-
// Build failed or there are still dependency errors; we'll try to install dependencies
518-
// ourselves
519-
if !buildSucceeded {
520-
log.Println("Build failed, continuing to install dependencies.")
521-
522-
shouldInstallDependencies = true
523-
} else if util.DepErrors("./...", modMode.argsForGoVersion(getEnvGoSemVer())...) {
524-
log.Println("Dependencies are still not resolving after the build, continuing to install dependencies.")
525-
526-
shouldInstallDependencies = true
527-
}
533+
shouldInstallDependencies = buildWithoutCustomCommands(modMode)
528534
} else {
529535
// write custom build commands into a script, then run it
530536
var (

0 commit comments

Comments
 (0)