Skip to content

Commit 0ac9a2a

Browse files
committed
Fix dbt YAML review file classification
1 parent 5c1fedf commit 0ac9a2a

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

packages/opencode/src/altimate/review/diff-filter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export type DbtFileKind =
5858
/** Classify a changed file by its role in a dbt project. */
5959
export function classifyDbtFile(path: string): DbtFileKind {
6060
const p = path.replace(/\\/g, "/").toLowerCase()
61+
const isYaml = p.endsWith(".yml") || p.endsWith(".yaml")
6162
if (/(^|\/)(dbt_project|profiles|packages|dependencies)\.ya?ml$/.test(p)) return "project_config"
6263
if (/(^|\/)macros\//.test(p)) return "macro"
6364
if (/(^|\/)snapshots\//.test(p)) return "snapshot"
@@ -66,7 +67,8 @@ export function classifyDbtFile(path: string): DbtFileKind {
6667
if (/(^|\/)analyses\//.test(p)) return "analysis"
6768
if (/(^|\/)models\//.test(p) && p.endsWith(".py")) return "python_model"
6869
if (/(^|\/)models\//.test(p) && p.endsWith(".sql")) return "model_sql"
69-
if (p.endsWith(".yml") || p.endsWith(".yaml")) return "schema_yml"
70+
if (isYaml && /(^|\/)(models|snapshots|seeds|tests)\//.test(p)) return "schema_yml"
71+
if (isYaml && /(^|\/)(_?schema|_?models|_?sources|sources|properties)\.ya?ml$/.test(p)) return "schema_yml"
7072
return "other"
7173
}
7274

packages/opencode/test/altimate/review-dbt-patterns.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ describe("dbt-patterns detectors", () => {
146146
expect(has(f, "test_coverage")).toBe(true)
147147
})
148148

149+
test("workflow YAML is not treated as schema.yml", () => {
150+
const f = detectSchemaYmlPatterns(
151+
{
152+
path: ".github/workflows/dbt-pr-review.yml",
153+
status: "modified",
154+
diff: "- - name: order_id\n- description: One row per order",
155+
},
156+
DEFAULT_RUBRIC,
157+
)
158+
expect(f.length).toBe(0)
159+
})
160+
149161
test("benign additive column produces NO dbt-pattern finding (precision)", () => {
150162
const sql = `select id, upper(status) as status_upper from {{ ref('x') }}`
151163
const f = detectModelPatterns(

0 commit comments

Comments
 (0)