Add EmitPrivateRegistryUsed

This commit is contained in:
Michael B. Gale
2026-02-02 14:39:27 +00:00
parent 8b03608a4f
commit a57c6cde30
2 changed files with 42 additions and 0 deletions

View File

@@ -568,3 +568,24 @@ func EmitExtractionFailedForProjects(path []string) {
noLocation,
)
}
func EmitPrivateRegistryUsed(writer DiagnosticsWriter, configs []string) {
lines := []string{}
for i := range configs {
lines = append(lines, fmt.Sprintf("* %s", configs[i]))
}
emitDiagnosticTo(
writer,
"go/autobuilder/analysis-using-private-registries",
"Go extraction used private package registries",
fmt.Sprintf(
"Go was extracted using the following private package registrie%s:\n\n%s\n",
plural(len(lines), "", "s"),
strings.Join(lines, "\n")),
severityNote,
fullVisibility,
noLocation,
)
}

View File

@@ -83,3 +83,24 @@ func Test_EmitCannotFindPackages_Actions(t *testing.T) {
// Custom build command suggestion
assert.Contains(t, d.MarkdownMessage, "If any of the packages are already present in the repository")
}
func Test_EmitPrivateRegistryUsed(t *testing.T) {
writer := newMemoryDiagnosticsWriter()
testItems := []string{
"* https://github.com/github/example (Git Source)",
"* https://example.com/goproxy (GOPROXY Server)",
}
EmitPrivateRegistryUsed(writer, testItems)
assert.Len(t, writer.diagnostics, 1, "Expected one diagnostic to be emitted")
d := writer.diagnostics[0]
assert.Equal(t, d.Source.Id, "go/autobuilder/analysis-using-private-registries")
assert.Equal(t, d.Severity, string(severityNote))
for i := range testItems {
assert.Contains(t, d.MarkdownMessage, testItems[i])
}
}