tools / godep

dependency tool for go
http://godoc.org/github.com/tools/godep
BSD 3-Clause "New" or "Revised" License
5.54k stars 455 forks source link

Added symlink evaluating to pathEqual #471

Closed michaeltrobinson closed 6 years ago

michaeltrobinson commented 8 years ago

This fixes an issue that occurs when your GOPATH contains a symlink and the dependency uses Mercurial.

Here is the minimal test program to show the problem:

package main

import (
    "fmt"

    "bitbucket.org/ww/goautoneg"
)

func main() {
    fmt.Println(goautoneg.Negotiate("", nil))
}
$ godep save -v ./...
godep: Go Version: go1.6
godep: No old Godeps.json found.
godep: Finding dependencies for [./...]
godep: Found package: zvelo.io/test
godep:  Deps: bitbucket.org/ww/goautoneg fmt sort strconv strings
godep: Computing new Godeps.json file
godep: Computing diff between old and new deps
godep: Deps to add:
godep:   bitbucket.org/ww/goautoneg
godep: Adding new dependencies
godep: save: skipping untracked file: /Users/michaelrobinson/.gvm/pkgsets/go1.6.2/global/src/bitbucket.org/ww/goautoneg/Makefile
godep: save: skipping untracked file: /Users/michaelrobinson/.gvm/pkgsets/go1.6.2/global/src/bitbucket.org/ww/goautoneg/README.txt
godep: save: skipping untracked file: /Users/michaelrobinson/.gvm/pkgsets/go1.6.2/global/src/bitbucket.org/ww/goautoneg/autoneg.go
godep: save: skipping test file: /Users/michaelrobinson/.gvm/pkgsets/go1.6.2/global/src/bitbucket.org/ww/goautoneg/autoneg_test.go
godep: Rewriting paths (if necessary)

As you can see, it skipped the goautoneg files. /Users/michaelrobinson/.gvm/pkgsets/go1.6.2/global/src is a symlink.

With the proposed changes:

$ godep save -v ./...
godep: Go Version: go1.6
godep: No old Godeps.json found.
godep: Finding dependencies for [./...]
godep: Found package: zvelo.io/test
godep:  Deps: bitbucket.org/ww/goautoneg fmt sort strconv strings
godep: Computing new Godeps.json file
godep: Computing diff between old and new deps
godep: Deps to add:
godep:   bitbucket.org/ww/goautoneg
godep: Adding new dependencies
godep: save: skipping test file: /Users/michaelrobinson/.gvm/pkgsets/go1.6.2/global/src/bitbucket.org/ww/goautoneg/autoneg_test.go
godep: Rewriting paths (if necessary)

My GOPATH/GOROOT

GOPATH=/Users/michaelrobinson/.gvm/pkgsets/go1.6.2/global:/Users/michaelrobinson/code/go GOROOT=/Users/michaelrobinson/.gvm/gos/go1.6.2

/Users/michaelrobinson/.gvm/pkgsets/go1.6.2/global/src points to /Users/michaelrobinson/code/go-thirdparty/src

The dependency in question (bitbucket.org/ww/goautoneg) uses Mercurial.

$ pwd
/Users/michaelrobinson/code/go-thirdparty/src/bitbucket.org/ww/goautoneg
$ hg status --all
C Makefile
C README.txt
C autoneg.go
C autoneg_test.go
freeformz commented 8 years ago

This needs to be fixed in the same way it was fixed for git. Resolving the symlink isn't acceptable. If mercurial is resolving the symlink then we need to change the behavior of mercurial to provide a path w/o resolving the symlinks for us. See also: https://github.com/tools/godep/commit/446e2f61cbc0bfa616de9b4b0cf6271945704a77

michaeltrobinson commented 8 years ago

I'm open to suggestions, but I haven't been able to figure out any way to get the un-resolved vcs root out of hg (but I am by no means a mercurial expert).

freeformz commented 8 years ago

ditto and mercurial is horribly untested inside of godep. ;-) I'll see if I can take a look later.

freeformz commented 6 years ago

Thanks, but I am closing this PR because the repo is going to be archived.