How do I diff generated files for an entity?

Table of Contents

entity diff is the post-generation complement to entity generate: it shows what actually changed on disk after files were written. For a pre-generation preview (without writing), use entity generate --diff instead — see How do I preview entity codegen changes as a diff?.

Question

How do I review what changed on disk after regenerating an entity?

Answer

Run compass codegen entity diff <name-or-id> after entity generate:

./compass.sh codegen entity generate country
./compass.sh codegen entity diff country

This runs git diff over every generated file for the entity — equivalent to collecting all output paths and passing them to git diff -- <files>, but without needing to know the paths.

The output is a standard unified diff that can be piped or paged:

./compass.sh codegen entity diff country | less
./compass.sh codegen entity diff country | delta

To restrict the diff to a single profile's files:

./compass.sh codegen entity diff country --profile sql

Once satisfied, stage the changes normally:

git add -p
git commit -m "[ores.refdata] Regenerate country"

Script

compass codegen entity diff is the _cmd_diff handler in projects/ores.compass/src/compass_codegen_entity.py. It calls git diff -- with the resolved output paths as arguments.

Tested by

Run ./compass.sh codegen entity generate country --profile sql followed by ./compass.sh codegen entity diff country --profile sql and verify the diff covers only the SQL output files.

See also

Emacs 29.1 (Org mode 9.6.6)