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

ensure: always write vendor even if not empty #889

Merged
merged 1 commit into from
Jul 31, 2017

Conversation

bradleyfalzon
Copy link
Contributor

@bradleyfalzon bradleyfalzon commented Jul 24, 2017

What does this do / why do we need it?

If the vendor directory already exists, and the lock file hasn't
changed, even though a project may be missing from the vendor
directory, dep ensure would not add the dependency to the vendor
folder.

If the project is in the vendor folder, but it has been modified
(no longer in sync with lock file), ensure would not replace the
dependency in the vendor folder.

This change causes dep ensure to run anytime there's a solution,
regardless of the state vendor folder is in, erring on the side
of replacing vendor without checking existing state which is the
most correct behaviour given the ensure intention.

Future optimisations may want to check and verify the contents of
the vendor folder before blinding replacing it.

What should your reviewer look out for in this PR?

Check the original issue #883, and then my initial proposal PR in #884, sdboyer then gave this solution a tentative OK in #883 (comment)

Do you need help or clarification on anything?

Edge cases, or any thoughts where this might be a bad idea. Such as if we've ever recommended doing in place edits to vendor directory.

No tests are included, as this is pretty critical behaviour, I presume an integration test or similar would be in order?

Which issue(s) does this PR fix?

Fixes #883.

Copy link
Member

@sdboyer sdboyer left a comment

Choose a reason for hiding this comment

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

yeah, i think i'm good with this - @ibrasho, does this seem sane to you? obviously this is going to mean slowdowns from all the extra writes, but can you think of any actual side effects?

@bradleyfalzon
Copy link
Contributor Author

I had been thinking about the slow downs, but dep ensure is a pretty deliberate action, I think users would be 100% OK with this.

But my main issue was dep ensure wasn't adding dependencies when they didn't exist, due to my workflow documented in README - we could implement the previous PR which only rebuilt vendor when the dependency was missing?

@sdboyer
Copy link
Member

sdboyer commented Jul 26, 2017

@bradleyfalzon oh no, no, i also think this is the right, safest solution for now, and that that's where need to start. i was just trying to draw @ibrasho's attention to some of the relevant considerations, here 😄

@ibrasho
Copy link
Collaborator

ibrasho commented Jul 28, 2017

Can't think of anything wrong with this atm.

Only nit is that the solution != nil check is useless (always true), since this function will return before this check if solution is nil anyway. But there is no harm is keeping in case the Solve method behavior changed.

@bradleyfalzon
Copy link
Contributor Author

Only nit is that the solution != nil check is useless (always true)

I agree @ibrasho, the docs suggests this too:

// Solve initiates a solving run. It will either complete successfully with
// a Solution, or fail with an informative error.

I think we should then remove the if block entirely.

If the vendor directory already exists, and the lock file hasn't
changed, even though a project may be missing from the vendor
directory, dep ensure would not add the dependency to the vendor
folder.

If the project is in the vendor folder, but it has been modified
(no longer in sync with lock file), ensure would not replace the
dependency in the vendor folder.

This change causes dep ensure to run anytime there's a solution,
regardless of the state vendor folder is in, erring on the side
of replacing vendor without checking existing state which is the
most correct behaviour given the ensure intention.

Future optimisations may want to check and verify the contents of
the vendor folder before blinding replacing it.

Fixes golang#883.
@bradleyfalzon bradleyfalzon force-pushed the ensure-always-vendor branch from 9bafc5f to 1aa2730 Compare July 28, 2017 10:13
@bradleyfalzon
Copy link
Contributor Author

I've amended the commit, @ibrasho can you review again?

@ibrasho
Copy link
Collaborator

ibrasho commented Jul 28, 2017

I'm good with this atm. 😁

@sdboyer I'm not sure where vendor verification is going to be triggered and how it affects the SafeWriter.writeVendor flag?

@sdboyer
Copy link
Member

sdboyer commented Jul 29, 2017

@sdboyer I'm not sure where vendor verification is going to be triggered and how it affects the SafeWriter.writeVendor flag?

once we have verification in place, we'll need to rewrite a few things, possibly including that flag. verification is likely to be at a different level, though, as verification will be on a per-project basis, not the whole vendor dir.

jbgo added a commit to jbgo/sftbot that referenced this pull request Jul 30, 2017
@sdboyer
Copy link
Member

sdboyer commented Jul 31, 2017

yep, i think we're good. in we go - thanks, @bradleyfalzon! 🎉

@sdboyer sdboyer merged commit 857a410 into golang:master Jul 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When vendor dir is part complete, dep ensure doesn't add missing dependencies
4 participants