Add ability to filter config options to files created after date - #2689
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2689 +/- ##
===========================================
- Coverage 95.51% 95.44% -0.07%
===========================================
Files 182 182
Lines 27830 27930 +100
===========================================
+ Hits 26582 26658 +76
- Misses 1248 1272 +24 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@calda is the idea of this feature to avoid formatting existing files? If so I had a slightly different idea in mind: I was thinking of adding a --snapshot feature that would capture the current state of the project, using the same hashing mechanism already employed by the cache. the snapshot file would be saved in the project as something like .swiftformat-snapshot. Any files that match the hashes in the snapshot would be ignored for future formatting passes. |
|
I think the snapshot idea is reasonable, but I think checking in a snapshot file is more complicated and visible than using the created-on date (for example, if a file is renamed, the snapshot file has to be updated). We also would need the ability to only ignore existing violations for specific rules, rather than just ignoring all existing violations in a file. I think both approaches are pretty reasonable with different situation where one makes more sense than the other. |
|
No reason not to have both I suppose, but the neat feature of a snapshot is that files that are touched get opted back into formatting, whereas with the creation date they don't. Unless you plan to support modified date as an alternative option? |
|
In our case we specifically only want to apply the |
5908303 to
741c3e4
Compare
b69d5ff to
a266e65
Compare
This PR adds the ability to apply options only to files created after a given date.
We already have the ability to apply options only within certain directories:
Following this design, we can support applying any options to file created after a certain date:
The quickest way to retrieve the creation date of the file is to retrieve it from the header comment. It could also make sense to support the Git creation date using something like
git-creation-date-after, but Git-integrated functionality is too expensive for our use case.