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

Use new gps capabilities during init's dep search #305

Merged
merged 3 commits into from
Mar 10, 2017

Conversation

sdboyer
Copy link
Member

@sdboyer sdboyer commented Mar 8, 2017

Also refactors a bit and adds some comments for clarity. Most importantly, this fixes #298.

Let's wait to merge this until after #287; I want to add a new test specifically for this case, but not until the new harness is ready.

Also refactors a bit and adds some comments for clarity.
@sdboyer sdboyer changed the title [WIP] Use new gps capabilities during init's dep search Use new gps capabilities during init's dep search Mar 9, 2017
Copy link
Contributor

@adg adg left a comment

Choose a reason for hiding this comment

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

Generally looks good, have a couple of Qs

cmd/dep/init.go Outdated
dependencies[pr] = append(dependencies[pr], ip)
}
vlogf("Building dependency graph...")
for _, ip := range rm.Flatten(false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you give this false a meaningful name?

eg

const foo = false
for _, ip := range rm.Flatten(foo) {

because right now I have no idea what false means here.

Copy link
Member Author

Choose a reason for hiding this comment

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

hah, interesting, i'd never thought to do something like that. sure, i can - the false just indicates that stdlib imports should be omitted.

@@ -350,13 +335,31 @@ func getProjectData(ctx *dep.Ctx, pkgT gps.PackageTree, cpr string, sm *gps.Sour
// project is not present in the workspace, and so we need to
// solve to deal with this dep.
r := filepath.Join(ctx.GOPATH, "src", string(pr))
_, err := os.Lstat(r)
if os.IsNotExist(err) {
fi, err := os.Stat(r)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the change from Lstat to Stat?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because, unless I misunderstand how this all works, we could Lstat a symlink that exists, but its referent does not. In that case, the subsequent check of os.IsNotExist() would not have the desired effect - it would tell us the symlink exists, but what we really care about is the referent existing.

...At least, I think that's what I think we care about here. My latest explorations into symlinks, and what we should do/the toolchain currently does left me dizzy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

@adg
Copy link
Contributor

adg commented Mar 10, 2017

Looks good.

@sdboyer sdboyer merged commit 70f818a into golang:master Mar 10, 2017
ibrasho pushed a commit to ibrasho-forks/dep that referenced this pull request May 10, 2017
Use new gps capabilities during init's dep search
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.

Ignore testdata, .* and _* dirs when scanning in init
3 participants