-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add output as JSON #158
Add output as JSON #158
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #158 +/- ##
===========================================
- Coverage 83.10% 70.55% -12.55%
===========================================
Files 23 22 -1
Lines 9338 6776 -2562
===========================================
- Hits 7760 4781 -2979
- Misses 1578 1995 +417
☔ View full report in Codecov by Sentry. |
This is a really neat PR! Do you have an expected use case in mind? (I only just learned about Difftastic and am curious about ways it could end up directly in the browser.) |
This would allow integration with delta as described in this issue |
I updated this PR by rebasing it on current master: https://github.com/withzombies/difftastic/tree/json |
anything missing from this PR? |
Up! @Wilfred is this PR dead? |
@akrantz01 what is the status of this PR ? :) |
Honestly not super sure, the project I had planned to use this for never really got started, so I no longer really have a use for it. However, I'm more than happy to rebase it to I'm currently dealing with final exams for uni, but I'll be able to get to it after this weekend. |
Cool, thanks for the update. |
Sorry for the delay on reviewing this. I was initially concerned about exposing internal details of difftastic types, which change pretty often. I see this is defining separate types, which largely solves that. This should probably be |
No worries! I think my original intention for the number field was to specify the line number. If that makes sense to keep, I'll rename it to |
Just rebased to the latest master with the proposed changes |
@Wilfred any updates on getting this reviewed and merged? |
Hey @akrantz01 @Wilfred just wanted to see if we can resolve conflicts and get this merged :) |
Merged in 11a96e5, thanks! :) This is pretty much the same code, just rebased on master and squashed. I've made two small changes: (1) This is a big increase in the exposed API to users, and I'm cautious about committing to this specific format. For now, I'm requiring (2) When diffing directories, difftastic will print the result of each file as soon as it's finished. This PR collected all the results and only printed at the end, so I've restored that behaviour. |
Resolves #73
This adds the ability to output the diff as JSON instead of text for both file and directory diffs. The individual token changes are all grouped by lines with left- and right-hand sides to preserve syntax awareness and make it clear which lines were changed.
Example outputs:
difft sample_files/json_before.json sample_files/json_after.json
difft sample_files/javascript_before.js sample_files/javascript_after.js