Skip to content

Commit

Permalink
fix: Ensure that we follow symlinks when testing current directory repo
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Feb 27, 2020
1 parent 644755b commit 40749af
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/pkg/repo/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,16 @@ func (d *Mapper) GetCurrentDirectoryRepo() (models.Repo, error) {
return nil, errors.Wrap(err, "repo: failed to get current directory")
}

if !strings.HasPrefix(dir, di.GetConfig().DevelopmentDirectory()) {
logrus.WithField("path", dir).Debug("Not within the development directory")
devDirectory, err := filepath.EvalSymlinks(di.GetConfig().DevelopmentDirectory())
if err != nil {
devDirectory = di.GetConfig().DevelopmentDirectory()
}

if !strings.HasPrefix(dir, devDirectory) {
logrus.WithField("path", dir).WithField("devdir", devDirectory).Debug("Not within the development directory")
return nil, nil
}

localDir := strings.Trim(filepath.ToSlash(dir[len(di.GetConfig().DevelopmentDirectory()):]), "/")
localDir := strings.Trim(filepath.ToSlash(dir[len(devDirectory):]), "/")
return d.GetFullyQualifiedRepo(localDir)
}

0 comments on commit 40749af

Please sign in to comment.