The :diff() pseudo-class matches packages whose files have changed
between the current working tree and a specified git commitish
reference. It uses git diff --name-only to determine changed files,
then maps them to packages by their file path location.
Syntax
:diff():diff(<commitish>)When called with no argument, defaults to HEAD (uncommitted
changes).
Examples
Uncommitted changes
Find packages with uncommitted changes:
$ vlt query ':diff()'Changes since a branch
Find packages changed since the main branch:
$ vlt query ':diff(main)'Changes since last commit
$ vlt query ':diff(HEAD~1)'Changes since a tag
$ vlt query ':diff("v1.0.0")'Only workspaces that changed
$ vlt query ':workspace:diff(main)'What gets selected
Given a monorepo where you changed files in packages/core/ and
packages/utils/ since main:
my-monorepo├── packages/core/ ← files changed├── packages/utils/ ← files changed├── packages/cli/└── apps/web/:diff(main) selects:
my-monorepo├── packages/core/ ✅ has changed files├── packages/utils/ ✅ has changed files├── packages/cli/└── apps/web/CI use cases
Run tests only for changed workspaces:
$ vlt query ':workspace:diff(main)' --view=json | xargs -I {} vlr test -w {}Find packages that depend on changed packages:
$ vlt query ':has(> :diff(main))'