How do I preview entity codegen changes as a diff?
Useful when a template has changed and you want to audit the impact on a specific entity before committing any regenerated files. See ores.codegen for background on profiles and templates.
Question
How do I see what would change if I regenerated an entity without writing to disk?
Answer
Pass --diff to compass codegen entity generate:
./compass.sh codegen entity generate country --diff
This generates all applicable profiles into a temp directory and prints a unified diff against the on-disk files. Nothing is written to the working tree.
To restrict to one profile:
./compass.sh codegen entity generate country --profile sql --diff
Sample output:
Diffing country (domain_entity, refdata) — 1 profile(s): sql --- a/projects/ores.sql/create/refdata/refdata_countries_create.sql +++ b/projects/ores.sql/create/refdata/refdata_countries_create.sql @@ -17,15 +17,16 @@ -/* +/** * AUTO-GENERATED FILE - DO NOT EDIT MANUALLY - * Template: sql_schema_create.mustache + * Template: sql_schema_domain_entity_create.mustache * To modify, update the template and regenerate. ...
If there are no differences, the command prints ✅ No differences. and
exits 0. If differences exist it exits 1 — useful in CI scripts.
--diff and --dry-run are mutually exclusive. Use --dry-run to list
output paths; use --diff to see content changes.
Script
--diff is handled by _diff_profiles in
projects/ores.compass/src/compass_codegen_entity.py. It calls
generate_from_model from codegen.core directly, capturing stdout and
suppressing logging to keep diff output clean.
Tested by
Run ./compass.sh codegen entity generate country --profile sql --diff
against a stale entity and verify a non-empty unified diff is printed with
no spurious log lines.