Skip to content

Commit

Permalink
Use subrepo FS for glob()
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatskaari committed Nov 15, 2023
1 parent 5f1eb0d commit 21ad656
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 0 additions & 8 deletions src/core/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ func (pkg *Package) TargetOrDie(name string) *BuildTarget {
return t
}

// SourceRoot returns the root directory of source files for this package.
// This is equivalent to .Name for in-repo packages but differs for those in subrepos.
func (pkg *Package) SourceRoot() string {
if pkg.Subrepo != nil {
return pkg.Subrepo.Dir(pkg.Name)
}
return pkg.Name
}

Check failure on line 70 in src/core/package.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/thought-machine/please) (gci)
// AddTarget adds a new target to this package with the given name.
// It doesn't check for duplicates.
Expand Down
8 changes: 6 additions & 2 deletions src/parse/asp/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,14 @@ func glob(s *scope, args []pyObject) pyObject {
allowEmpty := args[4].IsTruthy()
exclude = append(exclude, s.state.Config.Parse.BuildFileName...)
if s.globber == nil {
s.globber = fs.NewGlobber(fs.HostFS, s.state.Config.Parse.BuildFileName)
if s.pkg.Subrepo != nil {
s.globber = fs.NewGlobber(s.pkg.Subrepo.FS, s.state.Config.Parse.BuildFileName)
} else {
s.globber = fs.NewGlobber(fs.HostFS, s.state.Config.Parse.BuildFileName)
}
}

glob := s.globber.Glob(s.pkg.SourceRoot(), include, exclude, hidden, includeSymlinks)
glob := s.globber.Glob(s.pkg.Name, include, exclude, hidden, includeSymlinks)
if !allowEmpty && len(glob) == 0 {
// Strip build file name from exclude list for error message
exclude = exclude[:len(exclude)-len(s.state.Config.Parse.BuildFileName)]
Expand Down

0 comments on commit 21ad656

Please sign in to comment.