add ability to read symlink basedirs #438
Merged
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.
Imagine the following scenario: A user has a Go project. This directory is sitting in an arbitrary location in their file system and the user would like to keep it there. However, they need it to work with Go tooling, so they symlink it into an appropriate location in their GOPATH, e.g.
$GOPATH/src/github.com/user1/myproject
. The user then decides they's like to start using glide, so they cd to$GOPATH/src/github.com/user1/myproject
and runglide create
to generate their initialglide.yaml
file. The result is the creation of emptyglide.yaml
file. Sad times.What's happening is that the
basedir
given toNewResolver
is actually a symlink. This in turn causes an issue in theResolveLocal
function. Theif !fi.IsDir()
check fails since the basedir isn't actually a directory, it's a symlink.Let's add a check to the
NewResolver
function. After getting the absolute path of the providedbasedir
, let's check to see if it's a symlink. If it is, read the symlink and use that as the basedir instead. If not, proceed as normal.