Resolve vendor directory symlinks
diff --git a/path/strip.go b/path/strip.go
index 1162f38..cb5d118 100644
--- a/path/strip.go
+++ b/path/strip.go
@@ -11,14 +11,15 @@
// StripVcs removes VCS metadata (.git, .hg, .bzr, .svn) from the vendor/
// directory.
func StripVcs() error {
- if _, err := os.Stat(VendorDir); err != nil {
+ searchPath := VendorDir + string(os.PathSeparator)
+ if _, err := os.Stat(searchPath); err != nil {
if os.IsNotExist(err) {
msg.Debug("Vendor directory does not exist.")
}
return err
}
- return filepath.Walk(VendorDir, stripHandler)
+ return filepath.Walk(searchPath, stripHandler)
}
func stripHandler(path string, info os.FileInfo, err error) error {
@@ -40,7 +41,8 @@
// StripVendor removes nested vendor and Godeps/_workspace/ directories.
func StripVendor() error {
- if _, err := os.Stat(VendorDir); err != nil {
+ searchPath := VendorDir + string(os.PathSeparator)
+ if _, err := os.Stat(searchPath); err != nil {
if os.IsNotExist(err) {
msg.Debug("Vendor directory does not exist.")
}
@@ -48,33 +50,29 @@
return err
}
- err := filepath.Walk(VendorDir, stripVendorHandler)
+ err := filepath.Walk(searchPath, func(path string, info os.FileInfo, err error) error {
+ // Skip the base vendor directory
+ if path == searchPath || path == VendorDir {
+ return nil
+ }
+
+ name := info.Name()
+ if name == "vendor" {
+ if _, err := os.Stat(path); err == nil {
+ if info.IsDir() {
+ msg.Info("Removing: %s", path)
+ return os.RemoveAll(path)
+ }
+
+ msg.Debug("%s is not a directory. Skipping removal", path)
+ return nil
+ }
+ }
+ return nil
+ })
if err != nil {
return err
}
- err = strip.GodepWorkspace(VendorDir)
-
- return err
-}
-
-func stripVendorHandler(path string, info os.FileInfo, err error) error {
- // Skip the base vendor directory
- if path == VendorDir {
- return nil
- }
-
- name := info.Name()
- if name == "vendor" {
- if _, err := os.Stat(path); err == nil {
- if info.IsDir() {
- msg.Info("Removing: %s", path)
- return os.RemoveAll(path)
- }
-
- msg.Debug("%s is not a directory. Skipping removal", path)
- return nil
- }
- }
- return nil
+ return strip.GodepWorkspace(searchPath)
}