Ensure alignment of issue URL line is correct even
when the TODO line had any number of tab
characters prior to the issue title
Addresses remaining sub-issues of and
closes GitHub issue #245
Regardless of the OS on which the app is running,
respect the original line endings of the file
when writing back the issue URL. In the case of
a mixed line-ending file (e.g. both Windows-style
CRLF and Unix-style LF), the issue URL comment
line will use the line ending style of the TODO
comment line above it.
Partially addresses GitHub issue #245
Fix a regression that was accidentally introduced
with v5.1.2 which could cause an issue URL to not
be successfully added to the source file when
dealing with a CRLF (Windows-style line endings)
file on Linux.
Partially addresses GitHub issue #245
Provides a test for and the solution to GitHub
issue #242. Namely, an identifier which contains
regex characters (e.g. "[TODO]") is properly
handled by having the parser look for literal
"[" and "]" characters rather than treating those
characters as part of a regex pattern. The word
boundary regex pattern '\b' does NOT properly
handle this, so a slightly different pattern is
used to identify the boundary.
If TODO comment is a suffix to a line of
(executable) source, don't repeat the source
content when inserting the issue URL. But be sure
to still keep the same alignment.
Closes#229
Some parts of the code were using case-insensitive
matches when searching for an identifier (i.e.
TODO and todo would both be acceptable) whereas
other parts of the code would search for a strict
case-sensitive match (only TODO, not todo). This
inconsistency led to many issues, among them
- #216
- #224
- #225
Further, the identifier match wasn't being done
using word breaks, meaning an identifier of "FIX"
would match (case-insensitively) with "suffix" or
"prefix" if those words happened to appear in a
comment. (See #234).
Issue #230 was also preventing issue labels from
being applied properly if the identifier case
did not match exactly the canonical version. i.e.
"todo" would generate an issue, but the associated
labels wouldn't be applied because the exact
identifier used wasn't "TODO".
This commit resolves all of these issues.
Several related bugs that stem from a diff that
contains both deletions and additions. Specifically,
the line numbers aren't counted correctly, leading
to
- issue URL can't be inserted because it can't find
the right line in the latest file
- generated issue references the wrong line number
- closed issue references the wrong line number
See GitHub issue #236
The last item might not have any actual impact as
(I think) it's just informational. But it'd still
be better if it reported the correct line number
of the deletion, which necessarily has to be
relative to the _old_ file's line number, not the
updated file's.
As there is no solution in place yet for these
bugs, the unittest is marked as an expected failure
Added tests for issues #224/#225 and #229. Since
these are known bugs, the tests are currently
marked as expected failures. Once the solution
is implemented, that designation can be removed
and we'll still keep the test to make sure there
aren't any regressions.
Added a test which demonstrates a current bug where
if multiple TODOs with the same title appear in
the diff of the same file, only one of those issues
will have its URL succesfully inserted.
(Specifically, the first from the top.) As such,
the test is configured as an expected failure until
such time as the bug can be fixed.
The diff file has a couple of hunks which for
some unknown reason have parsing issues which
result in the wrong line being detected for where
the TODO is. This causes the issue URL insertion
to fail. That's its own issue that should be
investigated, but in order to allow the process_diff
unit test to pass, the diff file is being split
into two to isolate the trouble-causing hunks.
If regex characters are part of the title (for
example, parentheses), then this breaks the ability
to find the comment line when trying to insert
the issue URL. This commit escapes the title
to fix this problem.
Closes github.com/alstr/todo-to-issue-action#226
When searching for the comment line after which
the issue URL will be inserted, use a case-insensitive
search for the identifier portion of the line.
This matches how TodoParser identifies TODOs using
a case-insensitive search.
Closes github.com/alstr/todo-to-issue-action#224
There are issues currently where the wrong text
may be inserted in place of the issue URL. (See
github.com/alstr/todo-to-issue-action issues #224
, #225, and #226, for example.) When such a
situation is detected, the offending line is now
NOT inserted and instead a warning message is
printed out. This doesn't completely resolve
those issues, but mitigates against them and
other similar issues which may arise in the future.