-
Notifications
You must be signed in to change notification settings - Fork 1.3k
frontend: Use Cloud search for Go import badges #30350
Conversation
This commit fixes our Go import badges on sourcegraph.com, which have been broken since api.godoc.org was brought down. There's a [tracking issue](golang/go#36785) to re-introduce an API for pkg.go.dev, but it's not implemented yet. Instead, we implement a best-effort alternative that relies on searching `go.mod` files for the given repo name on sourcegraph.com. Sometimes packages will have different canonical names than their repositories, and we don't handle that case. There are [many open-source projects that have a broken badge](https://sourcegraph.com/search?q=context:global+sourcegraph.com+-/badge.svg&patternType=regexp). After this lands, they will recover.
Co-authored-by: Erik Seliger <erikseliger@me.com>
@@ -12,6 +12,7 @@ import ( | |||
"github.com/sourcegraph/sourcegraph/cmd/frontend/backend" | |||
"github.com/sourcegraph/sourcegraph/cmd/frontend/internal/routevar" | |||
"github.com/sourcegraph/sourcegraph/internal/database" | |||
"github.com/sourcegraph/sourcegraph/internal/httpcli" | |||
) | |||
|
|||
// TODO(slimsag): once https://github.com/badges/shields/pull/828 is merged, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we might be able to drop this TODO as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, that hasn't been done. I'm not sure what the exact steps would be here, so I'll let @slimsag comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of this TODO is that once shields.io has official badges for Sourcegraph, then we don't need our own endpoint that serves SVGs (and the serveRepoBadge
below could just redirect to shields.io directly.)
Looks like that PR was merged, so I believe we could do this today if we wanted to. If you search for Sourcegraph
on https://shields.io/ you'll see it's there:
And if you click the URL /sourcegraph/rrc
it pops up the builder UI:
But it seems like that badge design doesn't include the Sourcegraph logo, I guess when we added that customization on our side we never sent a PR to shields.io to add the logo there:
so yeah, idk, would it be nice to fix? maybe. but also maybe not worth the time.
Removed blackbox alerts here: https://github.com/sourcegraph/deploy-sourcegraph-cloud/pull/15386 |
This commit fixes our Go import badges on sourcegraph.com, which have been broken since api.godoc.org was brought down. There's a [tracking issue](golang/go#36785) to re-introduce an API for pkg.go.dev, but it's not implemented yet. Instead, we implement a best-effort alternative that relies on searching `go.mod` files for the given repo name on sourcegraph.com. Sometimes packages will have different canonical names than their repositories, and we don't handle that case. There are [many open-source projects that have a broken badge](https://sourcegraph.com/search?q=context:global+sourcegraph.com+-/badge.svg&patternType=regexp). After this lands, they will recover. Co-authored-by: Erik Seliger <erikseliger@me.com> Co-authored-by: Keegan Carruthers-Smith <keegan@sourcegraph.com>
This commit fixes our Go import badges on sourcegraph.com, which have been broken since api.godoc.org was brought down. There's a tracking issue to re-introduce an API for pkg.go.dev, but it's not implemented yet.
Instead, we implement a best-effort alternative that relies on searching
go.mod
files for the given repo name on sourcegraph.com. Sometimes packages will have different canonical names than their repositories, and we don't handle that case.There are many open-source projects that have a broken badge. After this lands, they will recover.
Tested locally by changing the target URL to sourcegraph.com rather than
internal.Client.URL
.