Skip to content

Commit 46ebc95

Browse files
anandgupta42claude
andcommitted
fix: dbt model detection for impact analysis at repo root
getChangedDBTModels compared absolute dbtProjectDir path against relative filenames, so the prefix filter never matched and impact analysis was always skipped. Fix: convert dbtProjectDir to relative path, and if dbt project is at repo root, return all dbt files without prefix filtering. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7a4b965 commit 46ebc95

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

dist/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27496,7 +27496,15 @@ function getChangedSQLFiles(ctx, maxFiles) {
2749627496
}
2749727497
function getChangedDBTModels(ctx, dbtProjectDir) {
2749827498
if (!dbtProjectDir) return ctx.dbtFiles;
27499-
const prefix = dbtProjectDir.endsWith("/") ? dbtProjectDir : `${dbtProjectDir}/`;
27499+
const workspace = process.env.GITHUB_WORKSPACE ?? process.cwd();
27500+
let relativeDir = dbtProjectDir;
27501+
if (dbtProjectDir.startsWith(workspace)) {
27502+
relativeDir = dbtProjectDir.slice(workspace.length).replace(/^\//, "");
27503+
}
27504+
if (!relativeDir || relativeDir === "." || relativeDir === "./") {
27505+
return ctx.dbtFiles;
27506+
}
27507+
const prefix = relativeDir.endsWith("/") ? relativeDir : `${relativeDir}/`;
2750027508
return ctx.dbtFiles.filter((f) => f.filename.startsWith(prefix));
2750127509
}
2750227510
function isInteractiveMention(triggers) {

dist/index.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context/pr.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,19 @@ export function getChangedDBTModels(
108108
): ChangedFile[] {
109109
if (!dbtProjectDir) return ctx.dbtFiles;
110110

111-
const prefix = dbtProjectDir.endsWith("/")
112-
? dbtProjectDir
113-
: `${dbtProjectDir}/`;
111+
// dbtProjectDir is absolute, filenames are relative — convert to relative
112+
const workspace = process.env.GITHUB_WORKSPACE ?? process.cwd();
113+
let relativeDir = dbtProjectDir;
114+
if (dbtProjectDir.startsWith(workspace)) {
115+
relativeDir = dbtProjectDir.slice(workspace.length).replace(/^\//, "");
116+
}
117+
118+
// If dbt project is at repo root, all dbt files match
119+
if (!relativeDir || relativeDir === "." || relativeDir === "./") {
120+
return ctx.dbtFiles;
121+
}
114122

123+
const prefix = relativeDir.endsWith("/") ? relativeDir : `${relativeDir}/`;
115124
return ctx.dbtFiles.filter((f) => f.filename.startsWith(prefix));
116125
}
117126

0 commit comments

Comments
 (0)