зеркало из https://github.com/github/codeql.git
Sometimes install Go version even when one exists
This commit is contained in:
Родитель
7323d4ecc1
Коммит
3f7a230a11
|
@ -737,12 +737,6 @@ func checkForUnsupportedVersions(v versionInfo) (msg, version string) {
|
|||
"). Writing an environment file not specifying any version of Go."
|
||||
version = ""
|
||||
diagnostics.EmitUnsupportedVersionGoMod(msg)
|
||||
} else if v.goEnvVersionFound && outsideSupportedRange(v.goEnvVersion) {
|
||||
msg = "The version of Go installed in the environment (" + v.goEnvVersion +
|
||||
") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion +
|
||||
"). Writing an environment file not specifying any version of Go."
|
||||
version = ""
|
||||
diagnostics.EmitUnsupportedVersionEnvironment(msg)
|
||||
}
|
||||
|
||||
return msg, version
|
||||
|
@ -768,10 +762,20 @@ func checkForVersionsNotFound(v versionInfo) (msg, version string) {
|
|||
}
|
||||
|
||||
if v.goEnvVersionFound && !v.goModVersionFound {
|
||||
msg = "No `go.mod` file found. Version " + v.goEnvVersion + " installed in the " +
|
||||
"environment. Writing an environment file not specifying any version of Go."
|
||||
version = ""
|
||||
diagnostics.EmitNoGoMod(msg)
|
||||
if outsideSupportedRange(v.goEnvVersion) {
|
||||
msg = "No `go.mod` file found. The version of Go installed in the environment (" +
|
||||
v.goEnvVersion + ") is outside of the supported range (" + minGoVersion + "-" +
|
||||
maxGoVersion + "). Writing an environment file specifying the maximum supported " +
|
||||
"version of Go (" + maxGoVersion + ")."
|
||||
version = maxGoVersion
|
||||
diagnostics.EmitNoGoModAndGoEnvUnsupported(msg)
|
||||
} else {
|
||||
msg = "No `go.mod` file found. Version " + v.goEnvVersion + " installed in the " +
|
||||
"environment is supported. Writing an environment file not specifying any " +
|
||||
"version of Go."
|
||||
version = ""
|
||||
diagnostics.EmitNoGoModAndGoEnvSupported(msg)
|
||||
}
|
||||
}
|
||||
|
||||
return msg, version
|
||||
|
@ -789,10 +793,18 @@ func compareVersions(v versionInfo) (msg, version string) {
|
|||
"file (" + v.goModVersion + ")."
|
||||
version = v.goModVersion
|
||||
diagnostics.EmitVersionGoModHigherVersionEnvironment(msg)
|
||||
} else {
|
||||
} else if outsideSupportedRange(v.goEnvVersion) {
|
||||
msg = "The version of Go installed in the environment (" + v.goEnvVersion +
|
||||
") is high enough for the version found in the `go.mod` file (" + v.goModVersion +
|
||||
"). Writing an environment file not specifying any version of Go."
|
||||
") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion + "). " +
|
||||
"Writing an environment file specifying the version of Go from the `go.mod` file (" +
|
||||
v.goModVersion + ")."
|
||||
version = v.goModVersion
|
||||
diagnostics.EmitVersionGoModSupportedAndGoEnvUnsupported(msg)
|
||||
} else {
|
||||
|
||||
msg = "The version of Go installed in the environment (" + v.goEnvVersion +
|
||||
") is supported and is high enough for the version found in the `go.mod` file (" +
|
||||
v.goModVersion + "). Writing an environment file not specifying any version of Go."
|
||||
version = ""
|
||||
diagnostics.EmitVersionGoModNotHigherVersionEnvironment(msg)
|
||||
}
|
||||
|
|
|
@ -49,13 +49,13 @@ func TestGetVersionToInstall(t *testing.T) {
|
|||
{"9999.0", true, "1.1", true}: "",
|
||||
{"9999.0", true, "", false}: "",
|
||||
// Go installation found with version below minGoVersion
|
||||
{"1.20", true, "1.2.2", true}: "",
|
||||
{"1.11", true, "1.2.2", true}: "",
|
||||
{"", false, "1.2.2", true}: "",
|
||||
{"1.20", true, "1.2.2", true}: "1.20",
|
||||
{"1.11", true, "1.2.2", true}: "1.11",
|
||||
{"", false, "1.2.2", true}: maxGoVersion,
|
||||
// Go installation found with version above maxGoVersion
|
||||
{"1.20", true, "9999.0.1", true}: "",
|
||||
{"1.11", true, "9999.0.1", true}: "",
|
||||
{"", false, "9999.0.1", true}: "",
|
||||
{"1.20", true, "9999.0.1", true}: "1.20",
|
||||
{"1.11", true, "9999.0.1", true}: "1.11",
|
||||
{"", false, "9999.0.1", true}: maxGoVersion,
|
||||
|
||||
// checkForVersionsNotFound()
|
||||
|
||||
|
|
|
@ -205,17 +205,6 @@ func EmitUnsupportedVersionGoMod(msg string) {
|
|||
)
|
||||
}
|
||||
|
||||
func EmitUnsupportedVersionEnvironment(msg string) {
|
||||
emitDiagnostic(
|
||||
"go/autobuilder/env-unsupported-version-in-environment",
|
||||
"Unsupported Go version in environment",
|
||||
msg,
|
||||
severityNote,
|
||||
telemetryOnly,
|
||||
noLocation,
|
||||
)
|
||||
}
|
||||
|
||||
func EmitNoGoModAndNoGoEnv(msg string) {
|
||||
emitDiagnostic(
|
||||
"go/autobuilder/env-no-go-mod-and-no-go-env",
|
||||
|
@ -238,10 +227,21 @@ func EmitNoGoEnv(msg string) {
|
|||
)
|
||||
}
|
||||
|
||||
func EmitNoGoMod(msg string) {
|
||||
func EmitNoGoModAndGoEnvUnsupported(msg string) {
|
||||
emitDiagnostic(
|
||||
"go/autobuilder/env-no-go-mod",
|
||||
"No `go.mod` file found",
|
||||
"go/autobuilder/env-no-go-mod-go-env-unsupported",
|
||||
"No `go.mod` file found and Go version in environment is unsupported",
|
||||
msg,
|
||||
severityNote,
|
||||
telemetryOnly,
|
||||
noLocation,
|
||||
)
|
||||
}
|
||||
|
||||
func EmitNoGoModAndGoEnvSupported(msg string) {
|
||||
emitDiagnostic(
|
||||
"go/autobuilder/env-no-go-mod-go-env-supported",
|
||||
"No `go.mod` file found and Go version in environment is supported",
|
||||
msg,
|
||||
severityNote,
|
||||
telemetryOnly,
|
||||
|
@ -260,6 +260,17 @@ func EmitVersionGoModHigherVersionEnvironment(msg string) {
|
|||
)
|
||||
}
|
||||
|
||||
func EmitVersionGoModSupportedAndGoEnvUnsupported(msg string) {
|
||||
emitDiagnostic(
|
||||
"go/autobuilder/env-version-go-mod-higher-than-go-env",
|
||||
"The Go version in `go.mod` file is higher than the Go version in environment",
|
||||
msg,
|
||||
severityNote,
|
||||
telemetryOnly,
|
||||
noLocation,
|
||||
)
|
||||
}
|
||||
|
||||
func EmitVersionGoModNotHigherVersionEnvironment(msg string) {
|
||||
emitDiagnostic(
|
||||
"go/autobuilder/env-version-go-mod-lower-than-or-equal-to-go-env",
|
||||
|
|
Загрузка…
Ссылка в новой задаче