facebookincubator / fastmod

A fast partial replacement for the codemod tool
Apache License 2.0
1.66k stars 41 forks source link

Diff panics when no changes #5

Closed dreid closed 6 years ago

dreid commented 6 years ago

If a file matches the regex but the substitution doesn't result in a diff fastmod panics.

This makes diffs_to_print return an empty vec if there are no diffs to print and makes print_diff return a bool indicating if it printed anything.

dreid commented 6 years ago

It looks like codemod avoids printing the filename for any empty diff so I've reorganized things slightly to calculate the diff up front and bail early if the diff is empty.