feat: precise --changed via stack-trace source file tracking; OTel sink docs

This commit is contained in:
John Dvorak
2026-05-22 15:00:04 -07:00
parent dab14ef77d
commit 6331933388
5 changed files with 111 additions and 18 deletions
+15 -9
View File
@@ -185,23 +185,29 @@ export async function getGitChangedFiles(cwd: string): Promise<string[]> {
}
/**
* Filter routes to only those modified in git.
* Filter routes to only those whose source file was modified in git.
* Uses sourceFile captured from stack traces during route registration.
* Falls back to path-segment heuristic when sourceFile is unavailable.
*/
export async function filterChangedRoutes(
routes: RouteContract[],
cwd: string,
): Promise<RouteContract[]> {
const changedFiles = await getGitChangedFiles(cwd)
// Map route paths to potential file paths (heuristic)
return routes.filter(route => {
// Prefer precise source file match
if (route.sourceFile) {
return changedFiles.some(file =>
route.sourceFile!.endsWith(file) || file.endsWith(route.sourceFile!)
)
}
// Fallback: heuristic path-segment match
const routePath = route.path
// Check if any changed file might contain this route
return changedFiles.some(file => {
// Simple heuristic: check if route path segments appear in file path
const segments = routePath.split('/').filter(Boolean)
return segments.some(segment => file.includes(segment))
})
const segments = routePath.split('/').filter(Boolean)
return changedFiles.some(file =>
segments.some(segment => file.includes(segment))
)
})
}