-
Notifications
You must be signed in to change notification settings - Fork 33
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
Fix versioned dependencies being removed during clone #91
base: master
Are you sure you want to change the base?
Conversation
If both a "versioned" and "non-versioned" version of a dependency exists in vendor.conf, the "longest" path should be cloned last, otherwise the versioned dependency may be deleted when cloning its non-versioned variant. For example, with the following vendor.conf: github.com/coreos/go-systemd/v22 v22.0.0 github.com/coreos/go-systemd v17 Running vndr would; 1. recursively delete "vendor/src/github.com/coreos/go-systemd/v22: 2. start cloning "github.com/coreos/go-systemd/v22" 3. recursively delete "vendor/src/github.com/coreos/go-systemd" 4. start cloning "github.com/coreos/go-systemd" This would lead to a conflicting situation; step 3. will remove the dependency that was previously cloned (or in the process of being cloned). This patch sorts the dependencies by import-path, cloning the shortest import paths first, which should prevent the race condition. Signed-off-by: Sebastiaan van Stijn <[email protected]>
@@ -55,6 +56,11 @@ func parseDeps(r io.Reader) ([]depEntry, error) { | |||
} | |||
|
|||
func cloneAll(vd string, ds []depEntry) error { | |||
// Sort dependencies so that longest import paths are handled last. This | |||
// prevents, e.g. "github.com/foo/bar" from deleting "github.com/foo/bar/v3" | |||
sort.Slice(ds, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does sort.Strings
not work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are structs, not a plain string slice
Omg, sorry, folks - Gmail ate my github label and I missed. Will review today. |
@thaJeztah Do you have time to try to write (or modify existing) unit-test? |
No worries; I was able to work around the issue by changing the order of the dependencies in the vendor.conf file, so it wasn't urgent.
I'll have a look at writing / adding a test case. I was a bit in a hurry writing this patch (so didn't spend much time looking for the tests)
… On 6 May 2020, at 20:53, Alexander Morozov ***@***.***> wrote:
@thaJeztah Do you have time to try to write (or modify existing) unit-test?
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
If both a "versioned" and "non-versioned" version of a dependency
exists in vendor.conf, the "longest" path should be cloned last,
otherwise the versioned dependency may be deleted when cloning its
non-versioned variant.
For example, with the following vendor.conf:
Running vndr would;
This would lead to a conflicting situation; step 3. will remove
the dependency that was previously cloned (or in the process
of being cloned).
This patch sorts the dependencies by import-path, cloning the
shortest import paths first, which should prevent the race condition.