Repository navigation
Commit afaca70
Leave files untouched when no migration applies (#8922)
* Leave files untouched when no migration applies
`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
Before (rescript):
let add = (a, b) => a + b
After (rescript):
let add = (a, b) => a + b
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.
Area: tools tests scripts
Output: unchanged
Tests: +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)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo
Signed-off-by: Christoph Knittel <ck@cca.io>
* Print migrate --stdout output without an extra newline
`rescript-tools migrate --stdout` printed its result with `print_endline`,
so every output ended with one newline more than the file would contain:
an unchanged file was not printed as is, and a migrated file gained a
trailing blank line. The output is now printed unchanged, so it equals the
file `migrate` would write.
Area: tools tests
Output: unchanged
Tests: ~tests/tools_tests/test.sh (NoMigration --stdout output must equal the
input byte for byte)
~tests/tools_tests/src/expected/*.expected (migrate fixtures lose the extra
trailing newline)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo
Signed-off-by: Christoph Knittel <ck@cca.io>
---------
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 32edc0a commit afaca70
33 files changed
Lines changed: 59 additions & 33 deletions
File tree
- changes
- scripts
- tests/tools_tests
- src
- expected
- migrate
- tools
- bin
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments