Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix internal dep hashing #358

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package-lock.json
.turbo
.vercel
cli/turbo
cli/turbo-new
cli/turbo-new.exe
cli/turbo.exe
.DS_Store
cache
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func (c *Context) populateTopologicGraphForPackageJson(pkg *fs.PackageJSON) erro
}
pkg.InternalDeps = make([]string, 0, internalDepsSet.Len())
for v := range internalDepsSet.List() {
pkg.ExternalDeps = append(pkg.InternalDeps, fmt.Sprintf("%v", v))
pkg.InternalDeps = append(pkg.InternalDeps, fmt.Sprintf("%v", v))
}
sort.Strings(pkg.InternalDeps)
sort.Strings(pkg.ExternalDeps)
Expand Down
18 changes: 10 additions & 8 deletions cli/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,15 @@ func (c *RunCommand) Run(args []string) int {
topoVisit = append(topoVisit, v)
pack := ctx.PackageInfos[v]

ancestralHashes := make([]string, len(pack.InternalDeps))
ancestralHashes := make([]string, 0, len(pack.InternalDeps))
if len(pack.InternalDeps) > 0 {
for i, ancestor := range pack.InternalDeps {
ancestralHashes[i] = ctx.PackageInfos[ancestor].Hash
for _, ancestor := range pack.InternalDeps {
if h, ok := ctx.PackageInfos[ancestor]; ok {
ancestralHashes = append(ancestralHashes, h.Hash)
}
}
sort.Strings(ancestralHashes)
}
sort.Strings(ancestralHashes)
var hashable = struct {
hashOfFiles string
ancestralHashes []string
Expand All @@ -315,7 +317,7 @@ func (c *RunCommand) Run(args []string) int {
vertexSet.Add(v)
}
// We remove nodes that aren't in the final filter set
for _, toRemove := range util.Set(vertexSet).Difference(filteredPkgs) {
for _, toRemove := range vertexSet.Difference(filteredPkgs) {
if toRemove != ctx.RootNode {
ctx.TopologicalGraph.Remove(toRemove)
}
Expand Down Expand Up @@ -845,13 +847,13 @@ func parseRunArgs(args []string, cwd string) (*RunOptions, error) {

// convertStringsToGlobs converts string glob patterns to an array glob.Glob instances.
func convertStringsToGlobs(patterns []string) (globss []glob.Glob, err error) {
var globs = make([]glob.Glob, len(patterns))
for i, pattern := range patterns {
var globs = make([]glob.Glob, 0, len(patterns))
for _, pattern := range patterns {
g, err := glob.Compile(pattern)
if err != nil {
return nil, err
}
globs[i] = g
globs = append(globs, g)
}

return globs, nil
Expand Down