Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Commit 8328bd4

Browse files
authored
fix issue where usages in a subpackage would be ignored (#53)
If a package was imported by a subpackage of a repository, the extension would try to look up the subpackage's import path as a repository name. For example, it would try to look up the repository named `github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend` at https://sourcegraph.com/github.com/sourcegraph/go-diff/-/blob/diff/print.go#L13:6&tab=references. This led to an error "Unable to find cross-repository references in ${repo}, probably because the repository was renamed and Sourcegraph does not support renamed repositories yet" that was erroneous. This fix chops off portions of the import path that are beyond the `github.com/owner/repo` name.
1 parent 12f4c8c commit 8328bd4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/lang-go.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,16 @@ async function repositoriesThatImportViaGDDO(
320320
const repoNames: string[] = (await Promise.all(
321321
response.results
322322
.map(result => result.path)
323-
.filter(repo =>
323+
.filter(path =>
324324
// This helps filter out repos that do not exist on the Sourcegraph.com instance
325-
repo.startsWith('github.com/')
325+
path.startsWith('github.com/')
326326
)
327+
.map(path => {
328+
// Chop off portion after "github.com/owner/repo".
329+
const parts = path.split('/')
330+
return parts.slice(0, 3).join('/')
331+
})
332+
.filter(repo => !!repo)
327333
.slice(0, limit)
328334
.map(async repo => {
329335
try {

0 commit comments

Comments
 (0)