fix: Remove "No newline" from previews #222
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a fix for #217 and possibly address #153 (comment).
When generating the preview, the
parse-diff
library is used to get the contents of new tweets, but was including\\ No newline at end of file
for new.tweet
files that are affected.This PR filters out lines in the diff that do not start with
+
, ensuring that only additional lines are actually included in the text of the parsed tweet.Perhaps there is a better approach to fixing than this PR, but the parse-diff library does not provide many options. If the diff passed to
parseDiff
is fully escaped (i.e.\\\\ No newline at end of file
), the library does remove this line from the list of additional lines.I have included a test case that uses the diff output from a sample run of of a newline tweet: https://github.com/IstoraMandiri/twitter-together-testing/actions/runs/3172702318/jobs/5167466385#step:2:8
Preview before this PR https://github.com/IstoraMandiri/twitter-together-testing/runs/8672961177
Preview after this PR https://github.com/IstoraMandiri/twitter-together-testing/runs/8672999162