Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

WIP - Import godep #589

Closed
wants to merge 20 commits into from
Closed

WIP - Import godep #589

wants to merge 20 commits into from

Conversation

darkowlzz
Copy link
Collaborator

Refer #577

Built on top of #500

Adds godep_config.go, godep_importer.go and tests.

@googlebot
Copy link
Collaborator

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@carolynvs
Copy link
Collaborator

@darkowlzz Woooooo! Reviewing now, I'll do my best to not cause too much grief as I work on getting #500 merged.

Copy link
Collaborator

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, there will be more changes most likely incoming as a result of whatever changes are requested against #500.

c, has := manifest.Dependencies[id.ProjectRoot]
if has {
// Create PairedVersion if constraint details are available
version := gps.NewVersion(c.Constraint.String())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! I completely forgot to pair the version in my PR. Nice catch! 😊

t.Fatalf("Expected the lock to have a project for 'github.com/sdboyer/deptest' but got '%s'", p.Ident().ProjectRoot)
}

lv := p.Version().String()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a check that the version was paired with a revision. After I updated glide to copy what you are doing, I updated the test with this:

https://github.com/carolynvs/dep/blob/import-glide/cmd/dep/glide_config_test.go#L84

["init", "-no-examples", "-skip-tools"]
],
"error-expected": "",
"gopath-initial": {},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pre-populate the gopath with the dependencies. This will:

a. Give us control over the versions used, so that they don't collide with the same versions in case 1. Right now the final Gopkg.lock is exactly the same between the two cases, making it hard to tell that the -skip-tools flag worked.
b. Protect the test from failing when new releases are added to the test repositories. By omitting the repo from gopath, the test now depends on pulling the repo from the network.

- Adds test for PariedVersion in godep_config.
- Adds dependency constraints in gopath-initial for godep integration
tests when -skip-tools is used. This differentiates final locks for with
and without tools.
@darkowlzz
Copy link
Collaborator Author

Added the suggested test changes.

FYI, there will be more changes most likely incoming as a result of whatever changes are requested against #500.

@carolynvs that's alright. Now we have working godep importer code. Once #500 is merged, we can just take the few godep parts from this PR and use them later.
Thanks for reviewing :)

@sdboyer
Copy link
Member

sdboyer commented May 17, 2017

without having looked at the code in the PR yet at all, lemme just note that, given that Godep only ever stores commit hashes, probably the best route to follow is to transform it only into a lock - no manifest. We should also attempt to convert commit hashes into more friendly user-facing versions, if any are available.

rootL.P[i] = lp
}
}
}
Copy link
Collaborator Author

@darkowlzz darkowlzz May 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carolynvs a little problem here. Overlaying of lock isn't happening in some cases.

Let's take the example of integration test init/godep/case1/.
In godep/case1/testcase.json, although gopath-initial contains deptest, since deptest is a transitive dependency, the default (first analyzer) doesn't adds it to the manifest or lock it generates. And since there's no deptestdos in gopath-initial, the first analyzer generates empty (not nil) manifest and lock structs.
Now in the above code, when overlay is attempted for lock with godep analyzer generated manifest and lock,

for i, existingLP := range rootL.P {

is skipped because rootL is empty from the first analyzer run. And no lock overlay happens.

Makes sense?

The final lock in init/godep/case1/ is incorrect at the moment. Commit hash in final lock is different from the one in Godep.json.

UPDATE: I see you have changed the overlay code in #500 and now it's handling this case :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah found that I broke overlay at some point. I have a bunch of fixes/pr feedback I'll push tonight. 😊

break
}
}
}
Copy link
Collaborator Author

@darkowlzz darkowlzz May 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdboyer @carolynvs ^ tries to fetch version for a given commit hash. Is there anything, that you can think of, is available and I could have reused?

Copy link
Collaborator

@carolynvs carolynvs May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how I would have done it. It seems useful enough that either a) it already exists in gps somewhere or b) would be a very nice function to extract out for other importers to use.

I had to do something similar for finding the default branch and ended up putting that logic into deduceConstraint. https://github.com/carolynvs/dep/blob/import-glide/cmd/dep/ensure.go#L310

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is - have a look at version_unifier.go. Actually, there's a whole pile of logic for this, but it's all hidden away unexported inside gps, as it's encoded as an extension to the Version system, and I didn't want to leak an extra type out there.

I'd strongly prefer we not leak that unifier type publicly - note the unconditional panics in certain of the interface's method implementations - but we could expose some alternate frontend to it.

I've also been thinking that we might want to export the source interface (and from there, sourceGateways), and include such methods on it. That's probably out of scope for immediate needs, though...

- Fetches versions list of project and looks for version corresponding
to the given revision.
- Adds test TestGodepConvertBadInput_EmptyPackageName for the same.
@carolynvs
Copy link
Collaborator

@darkowlzz #500 was just merged with lots of changes. Notably the config and importer structs were merged into a single struct and the interface tweaked slightly. Also I stole your logic for pairing a revision with a version and called the function lookupVersionForRevision. 💖

I know a ton has changed out from underneath you, happy to answer any questions or help move this over!

@carolynvs carolynvs mentioned this pull request Jun 6, 2017
@darkowlzz
Copy link
Collaborator Author

Closing this in favor of #742 .

@darkowlzz darkowlzz closed this Jun 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants