alstr/todo-to-issue-action

various whitespace issues

Closed this issue · 1 comments

There are a number of issues regarding whitespace that affect issue URL insertion.

  • a CRLF (Windows-style line endings) is completely rewritten using LF (Unix-style) line endings
  • a mixed file (both CRLF- and LF-terminated lines) is completely rewritten using LF line endings
  • a CRLF-terminated line will fail to have the issue URL inserted due to being unable to match the line to the issue title
    • this is actually a regression introduced by v5.1.2. Earlier versions would have still inserted the line, albeit with the problems noted above

Goal should be to respect the line endings of the original file as much as possible, regardless of the platform on which the application is running. Most of the above is stemming from the fact that Python's readlines() and writelines() tries to be helpful by, respectively, stripping off line endings when reading and inserting the platform-specific default line endings when writing. A more nuanced approach would be to leave existing lines as-is and only insert the issue URL line (using whatever line ending is appropriate).

(This could/should be multiple issues, but I'm feeling a little lazy and as they'll all be resolved with the same PR, I'm clumping them all together.)


EDIT

Also forgot to mention another issue:

  • tab characters aren't properly handled
    • PR #241 didn't account for tabs on the TODO line, which can lead to alignment issues for the issue URL comment

PR is forthcoming