Fix versioned dependencies being removed during clone#91
Open
thaJeztah wants to merge 1 commit intoLK4D4:masterfrom
Open
Fix versioned dependencies being removed during clone#91thaJeztah wants to merge 1 commit intoLK4D4:masterfrom
thaJeztah wants to merge 1 commit intoLK4D4:masterfrom
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 <github@gone.nl>
cpuguy83
reviewed
Apr 29, 2020
| 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 { |
Collaborator
Author
There was a problem hiding this comment.
These are structs, not a plain string slice
Owner
|
Omg, sorry, folks - Gmail ate my github label and I missed. Will review today. |
Owner
|
@thaJeztah Do you have time to try to write (or modify existing) unit-test? |
Collaborator
Author
|
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.