New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add importer for github.com/LK4D4/vndr #978

Merged
merged 7 commits into from Aug 11, 2017

Conversation

Projects
None yet
5 participants
@spenczar
Copy link
Contributor

spenczar commented Aug 8, 2017

This was motivated by working on something that imports github.com/moby/moby, which uses github.com/LK4D4/vndr. I understand that, in the future, dep will use importers to understand the manifests of transitive dependencies to construct an appropriate dependency graph. That would be really useful when working with moby!

@carolynvs, thanks for your guidance in slack. I followed the pattern set by godep_importer.go and glide_importer.go.

spenczar added some commits Aug 8, 2017

@carolynvs
Copy link
Collaborator

carolynvs left a comment

THIS LOOKS AWESOME! 🎉

Would you please also add an end-to-end test? I suggest copying and tweaking the godep test from here: https://github.com/golang/dep/tree/master/cmd/dep/testdata/harness_tests/init/godep/case1

To run just that single test you can use:

go test -run TestIntegration/init/vndr ./cmd/dep -v -logs
return nil, nil, errors.Wrapf(err, "unable to load vndr file")
}

manifest := &dep.Manifest{

This comment has been minimized.

@carolynvs

carolynvs Aug 9, 2017

Collaborator

Note to self: If #952 is merged first, we should use the constructor dep.NewManifest.

This comment has been minimized.

@spenczar

spenczar Aug 10, 2017

Contributor

The race is on! 🏁

"github.com/pkg/errors"
)

func TestVndrConfig_Import(t *testing.T) {

This comment has been minimized.

@carolynvs

carolynvs Aug 9, 2017

Collaborator

My apologies for not giving a heads up that this was incoming before you started... Another PR was just merged which switched the importers to table based tests. Below is an example of how the tests should look now. I hope it's not too much trouble to update the tests here to match, let me know if they don't line up well, I see you are testing slightly differently (using deep equal).

func TestGodepConfig_Convert(t *testing.T) {
testCases := map[string]struct {
json godepJSON
wantConvertErr bool
matchPairedVersion bool
projectRoot gps.ProjectRoot
wantConstraint string
wantRevision gps.Revision
wantVersion string
wantLockCount int
}{
"convert project": {
json: godepJSON{
Imports: []godepPackage{
{
ImportPath: "github.com/sdboyer/deptest",
// This revision has 2 versions attached to it, v1.0.0 & v0.8.0.
Rev: "ff2948a2ac8f538c4ecd55962e919d1e13e74baf",
Comment: "v0.8.0",
},
},
},
matchPairedVersion: true,
projectRoot: gps.ProjectRoot("github.com/sdboyer/deptest"),
wantConstraint: "^0.8.0",
wantRevision: gps.Revision("ff2948a2ac8f538c4ecd55962e919d1e13e74baf"),
wantVersion: "v0.8.0",
wantLockCount: 1,
},

This comment has been minimized.

@spenczar

spenczar Aug 10, 2017

Contributor

No problem, this was pretty easy to do.

There's now a lot of repeated code between the three importers, though. I've got a sketch of how this could be resolved in spenczar/dep@vndr_importer...importer_test_refactor. It makes things a more abstract, which is bad, but it reduces the code duplication, which is good. If you think this is a net positive, let me know and I'll make an actual PR - up to you, I can see it either way.

This comment has been minimized.

@carolynvs

carolynvs Aug 11, 2017

Collaborator

@spenczar Oops! I missed this comment until just now. Want to take a look at #992? I think we both approached it about the same.

Source: pkg.repository,
},
}
pc.Constraint, err = v.sm.InferConstraint(pkg.revision, pc.Ident)

This comment has been minimized.

@carolynvs

carolynvs Aug 9, 2017

Collaborator

I know that moby uses short git hashes, which is a bit of a problem. I think it would be easiest to have that be a separate issue, so I created #987 to address that part.

@AlekSi

This comment has been minimized.

Copy link
Contributor

AlekSi commented Aug 10, 2017

Poke @LK4D4

@carolynvs carolynvs merged commit 4f22124 into golang:master Aug 11, 2017

4 checks passed

cla/google All necessary CLAs are signed
codeclimate All good!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@carolynvs carolynvs referenced this pull request Aug 11, 2017

Closed

Alternate init modes #186

carolynvs added a commit to carolynvs/dep that referenced this pull request Aug 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment