rescript-tools migrate leave files untouched when no migration applies instead of reformatting them.Leave files untouched when no migration applies
๐ Bug fixtoolstestsscripts
rescript-tools migrate and migrate-all reprinted every file whose printed form differed from the source, so files without any migration were reformatted and reported as migrated. A file is now reprinted only when the migration mapper changed its AST; otherwise it stays byte-identical, is reported as not needing migration, and --stdout prints the source as is.
Example ReScript
let add = (a, b) => a + b
let add = (a, b) => a + blet add = (a, b) => a + b๐ Bug fixMake
Review
- Why compare ASTs instead of checking for deprecated uses? A deprecation without a migration template rewrites nothing, and the
todo_extension rename applies without any deprecation; the AST comparison covers both.
- No effect
- Output: unchanged
- Tests
- other+ tests/tools_tests/src/migrate/NoMigration.res+ tests/tools_tests/src/migrate/NoMigration.resi+ tests/tools_tests/src/expected/NoMigration.res.expected+ tests/tools_tests/src/expected/NoMigration.resi.expected~ tests/tools_tests/test.sh (in-place migrate must keep the files unchanged)
- Changelog fragment changes/migrate-only-changed-files.fix.md
- No committed generated JS changes
10 files ยท +55 โ10 ยท changelog 1 ยท scripts 2 ยท tests 5 ยท tools 2
| A | changes/migrate-only-changed-files.fix.md | +1 | โ0 |
| M | scripts/format.sh | +1 | โ1 |
| M | scripts/format_check.sh | +1 | โ1 |
| A | tests/tools_tests/src/expected/NoMigration.res.expected | +8 | โ0 |
| A | tests/tools_tests/src/expected/NoMigration.resi.expected | +6 | โ0 |
| A | tests/tools_tests/src/migrate/NoMigration.res | +7 | โ0 |
| A | tests/tools_tests/src/migrate/NoMigration.resi | +5 | โ0 |
| M | tests/tools_tests/test.sh | +10 | โ0 |
| M | tools/src/migrate.md | +1 | โ0 |
| M | tools/src/migrate.ml | +15 | โ8 |