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

Commit 655e229

Browse files
author
Max Schaefer
committed
Revert "Revert "autobuilder: Add support for GITHUB_REPOSITORY environment variable""
This reverts commit ccfccb4.
1 parent 1821cca commit 655e229

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This behavior can be further customized using environment variables: setting LGT
3434
to 'false' disables the GOPATH set-up, CODEQL_EXTRACTOR_GO_BUILD_COMMAND (or alternatively
3535
LGTM_INDEX_BUILD_COMMAND), can be set to a newline-separated list of commands to run in order to
3636
install dependencies, and LGTM_INDEX_IMPORT_PATH can be used to override the package import path,
37-
which is otherwise inferred from the SEMMLE_REPO_URL environment variable.
37+
which is otherwise inferred from the SEMMLE_REPO_URL or GITHUB_REPOSITORY environment variables.
3838
3939
In resource-constrained environments, the environment variable CODEQL_EXTRACTOR_GO_MAX_GOROUTINES
4040
(or its legacy alias SEMMLE_MAX_GOROUTINES) can be used to limit the number of parallel goroutines
@@ -100,13 +100,19 @@ func getImportPath() (importpath string) {
100100
if importpath == "" {
101101
repourl := os.Getenv("SEMMLE_REPO_URL")
102102
if repourl == "" {
103-
log.Printf("Unable to determine import path, as neither LGTM_INDEX_IMPORT_PATH nor SEMMLE_REPO_URL is set\n")
104-
return ""
105-
}
106-
importpath = getImportPathFromRepoURL(repourl)
107-
if importpath == "" {
108-
log.Printf("Failed to determine import path from SEMMLE_REPO_URL '%s'\n", repourl)
109-
return
103+
githubrepo := os.Getenv("GITHUB_REPOSITORY")
104+
if githubrepo == "" {
105+
log.Printf("Unable to determine import path, as neither LGTM_INDEX_IMPORT_PATH nor GITHUB_REPOSITORY is set\n")
106+
return ""
107+
} else {
108+
importpath = "github.com/" + githubrepo
109+
}
110+
} else {
111+
importpath = getImportPathFromRepoURL(repourl)
112+
if importpath == "" {
113+
log.Printf("Failed to determine import path from SEMMLE_REPO_URL '%s'\n", repourl)
114+
return
115+
}
110116
}
111117
}
112118
log.Printf("Import path is '%s'\n", importpath)

0 commit comments

Comments
 (0)