From a57c6cde309d8d6d908ae1fc4e36087b5081f215 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Mon, 2 Feb 2026 14:39:27 +0000 Subject: [PATCH] Add `EmitPrivateRegistryUsed` --- go/extractor/diagnostics/diagnostics.go | 21 ++++++++++++++++++++ go/extractor/diagnostics/diagnostics_test.go | 21 ++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/go/extractor/diagnostics/diagnostics.go b/go/extractor/diagnostics/diagnostics.go index a91a9efac0d..b40b31c15f3 100644 --- a/go/extractor/diagnostics/diagnostics.go +++ b/go/extractor/diagnostics/diagnostics.go @@ -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, + ) +} diff --git a/go/extractor/diagnostics/diagnostics_test.go b/go/extractor/diagnostics/diagnostics_test.go index f2b560004ba..1582923fb55 100644 --- a/go/extractor/diagnostics/diagnostics_test.go +++ b/go/extractor/diagnostics/diagnostics_test.go @@ -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]) + } +}