sourcegraph / srclib-go

Go toolchain for srclib
https://sourcegraph.com/sourcegraph/srclib-go
MIT License
29 stars 13 forks source link

depresolve: use newer tools/go/vcs package to resolve import paths #86

Closed pararthshah closed 8 years ago

pararthshah commented 8 years ago

This changes the ResolveDep method to use the vcs.RepoRootForImportPath method to resolve external package import paths, which is more stable than the earlier gosrc.Get call. Additionally, this new call does not incur a GitHub API request.

This change also makes it so that the Unit name of the resolved dep is modified to have the base set to the root of the clone URL of the repo. This ensures that the ref is resolved to the proper def, since the def will not have a custom import path in its unit name when graphed by srclib-go (since srclib-go does not have information about a repo's custom import paths).

For eg, the golang.org/x/net/context.Context def will have the def key: Repo: github.com/golang/net Unit: github.com/golang/net/context UnitType: GoPackage Path: Context

Note how the Unit name is 'github.com/golang/net/context' and not 'golang.org/x/net/context'. This change ensures that refs to such defs are always resolved correctly.

pararthshah commented 8 years ago

@shurcooL I have a feeling that you will like this change 😄

dmitshur commented 8 years ago

since the def will not have a custom import path in its unit name when graphed by srclib-go (since srclib-go does not have information about a repo's custom import paths).

Are we choosing this path because the alternative - providing the import path corresponding to repo root to srclib-go - is very hard to achieve? Or another reason?

pararthshah commented 8 years ago

That's correct. Going the other way will involve a bigger change at srclib level. That is probably the better long term solution. On Apr 26, 2016 10:48 AM, "Dmitri Shuralyov" notifications@github.com wrote:

since the def will not have a custom import path in its unit name when graphed by srclib-go (since srclib-go does not have information about a repo's custom import paths).

Are we choosing this path because the alternative - providing the import path corresponding to repo root to srclib-go - is very hard to achieve? Or another reason?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/sourcegraph/srclib-go/pull/86#issuecomment-214825759

beyang commented 8 years ago

1 comment, otherwise LGTM