Skip to content

Commit

Permalink
Include entry packages, not just dependencies when checking changed p…
Browse files Browse the repository at this point in the history
…ackages. (#950)

When we're matching dependencies, make sure to check if the named package is the one that changed
  • Loading branch information
gsoltis committed Mar 25, 2022
1 parent e302403 commit fbfc606
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cli/internal/scope/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ func (r *Resolver) filterSubtreesWithSelector(selector *TargetSelector) (util.Se
return nil, err
}
for changedPkg := range changedPkgs {
if deps.Include(changedPkg) {
if !selector.excludeSelf && pkg == changedPkg {
roots.Add(pkg)
break
}
if deps.Include(changedPkg) {
roots.Add(pkg)
matched.Add(changedPkg)
break
Expand Down
13 changes: 13 additions & 0 deletions cli/internal/scope/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,19 @@ func Test_SCM(t *testing.T) {
},
// Note: missing test here that takes advantage of automatically exempting
// test-only changes from pulling in dependents
//
// turbo-specific tests below here
{
"changed package was requested scope, and we're matching dependencies",
[]*TargetSelector{
{
diff: "HEAD~1",
namePattern: "package-1",
matchDependencies: true,
},
},
[]string{"package-1"},
},
}

for _, tc := range testCases {
Expand Down

1 comment on commit fbfc606

@vercel
Copy link

@vercel vercel bot commented on fbfc606 Mar 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.