Skip to content
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

numerous bug fixes #228

Merged
merged 15 commits into from
Nov 11, 2024
Merged

numerous bug fixes #228

merged 15 commits into from
Nov 11, 2024

Conversation

rgalonso
Copy link
Contributor

@rgalonso rgalonso commented Nov 9, 2024

This PR addresses a number of bug fixes as well as adding a new test to demonstrate an existing bug (which this PR does not fix).

Relevant issues:

Issues #216, #224, and #225 all stem from the same root cause: the app doesn't properly handle a diff that introduces the same-titled TODO multiple times into the same file. This PR does NOT fix that root issue (a separate PR will do so though), but it DOES address the unintended side effect of introducing other, erroneous, lines into the source code. It will also prevent any future errors of this same class.

Fix bug where if there were multiple issue URLs
to insert into a file, after the first insertion
all further insertions would copy a "random"
line (based on *original* line numbering) and
insert that copy rather than the issue URL.

Now processes files in order by file name
and then in reverse order by line number,
thereby ensuring that any line insertions/
deletions at bottom of file don't affect
line numbering above them.

Closes github.com/alstr#225
test_new.diff had some issues which would cause
errors if trying to actually use the diff file
with 'patch' to create the files it references.

1) had some line numbers which were invalid
2) had path specifications and, unfortunately,
   'patch' does not support creating absent directories

The file has been cleaned up to have the create
line numbers and to assume that all files are at
the root.

Additionally, for the few cases where the diff
file referred to an edit rather than creation of a
whole new file, those diff hunks were moved into a
new, separate, file.

There is no functional change with this commit,
but it sets up future test features.
No functional change, but enables future changes
will allow more of the code to be exercised by
unittest.
Reads the diff file to generate a simulated
filesystem, inserts the URL comments into these
new files, and then parses the output to confirms
that all of the issues that were expected to be
created were created.
Insertion of the URL is different from simply
creating/updating the issue, so we want to have
this level of output to ensure that as many
file updates as expected are actually occurring.

Note: The unit test is currently failing!
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 alstr#224
, alstr#225, and alstr#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.
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#224
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#226
Wrong line numbering is causing issue URLs to not
be inserted when processing this diff file
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.
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.
@rgalonso
Copy link
Contributor Author

rgalonso commented Nov 9, 2024

@alstr, FYI that this PR is ready for your review. Thanks.

I initially thought it a good idea to split these
up, but it led to a lot of unnnecessary code
redundancy. This is a better approach.
Added tests for issues alstr#224/alstr#225 and alstr#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.
@alstr alstr merged commit 5aa95f6 into alstr:master Nov 11, 2024
1 check passed
@alstr
Copy link
Owner

alstr commented Nov 11, 2024

Great work, thanks! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

repeat of TODO comment line inserted instead of issue URL
2 participants