Commit Graph

590 Commits

Author SHA1 Message Date
Robert Alonso
dd15f79ab8 feat: add ability to print Issue object
Facilitates debug and error handling
2024-11-11 17:53:48 +00:00
Robert Alonso
e42bca636e refactor: add optional argument to TodoParser to set configuration
Currently, this is just used to set identifiers
without needing to modify the environment, but this
could (should?) be extended to other options
2024-11-11 17:52:38 +00:00
Alastair Mooney
5aa95f6c12
Merge pull request #228 from rgalonso/bug-fixes
numerous bug fixes
2024-11-11 13:16:30 +00:00
Robert Alonso
2997380286 test: added tests for known bugs
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.
2024-11-10 04:28:37 +00:00
Robert Alonso
30b3d43dec refactor: consolidate test classes
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.
2024-11-09 19:56:03 +00:00
Robert Alonso
325fbaf03b test: add additional test demonstrating current bug
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.
2024-11-09 19:28:09 +00:00
Robert Alonso
61cb584226 refactor: split unit test class to have a common base class 2024-11-09 19:28:09 +00:00
Robert Alonso
d57788aa0b fix: split diff file to allow process_diff unit test to pass
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.
2024-11-09 19:28:09 +00:00
Robert Alonso
246bf5d5bf fix: fix additional formatting issues with diff file
Wrong line numbering is causing issue URLs to not
be inserted when processing this diff file
2024-11-09 19:28:09 +00:00
Robert Alonso
b4b115f060 fix: escape title when searching for comment line
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
2024-11-09 19:28:09 +00:00
Robert Alonso
f752af8130 fix: perform case-insensitive search for identifier
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
2024-11-09 19:28:09 +00:00
Robert Alonso
06c95362da fix: safety check before inserting new line
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.
2024-11-09 19:28:09 +00:00
Robert Alonso
cd754de86c test: print message when issue URL has actually been inserted
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!
2024-11-09 19:28:08 +00:00
Robert Alonso
590a050199 test: add test to exercise main's process_diff()
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.
2024-11-09 19:28:08 +00:00
Robert Alonso
80b555cdce refactor: allow process_diff() output to be redirected 2024-11-09 19:28:08 +00:00
Robert Alonso
829b294c5f refactor: move bulk of main's processing into separate method
No functional change, but enables future changes
will allow more of the code to be exercised by
unittest.
2024-11-09 19:28:08 +00:00
Robert Alonso
da6872a340 refactor: clean up and split off diff file
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.
2024-11-09 19:28:08 +00:00
Robert Alonso
d81fdc509c fix: insert issue URLs at correct line number
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/todo-to-issue-action#225
2024-11-09 19:28:08 +00:00
Alastair Mooney
efb8b9830d
Update main.py
Fix import errors
2024-11-05 10:03:59 +00:00
Alastair Mooney
4b44510149
Update test_todo_parser.py
Fix import error
2024-11-05 09:51:15 +00:00
Alastair Mooney
1484e53cbd
Update GitHubClient.py
Add server URL to GitHub Client

Resolve conflict in #218
2024-11-05 09:48:38 +00:00
Alastair Mooney
3ba2647ea6
Merge pull request #218 from kazuma0129/support-ghe
Fix link generation for GitHub Enterprise by using `GITHUB_SERVER_URL`
2024-11-05 09:44:19 +00:00
Alastair Mooney
37b15115ba
Merge branch 'master' into support-ghe 2024-11-05 09:43:35 +00:00
Alastair Mooney
d8db8a9571
Merge pull request #222 from rgalonso/refactor-and-add-tests
refactor and add tests
2024-11-05 09:30:25 +00:00
Robert Alonso
649e50253b test: add unittest to run mypy
New unittest file consists of two tests. Both
run mypy, but one does so with arguments that are
expected to allow the test to pass. The other does
not provide those arguments and is expected to fail.
The expected failure is intentional, to serve as
an ongoing reminder to try to 1) move towards having
strict typing in the codebase and to 2) not
add any additional errors/warnings in the meantime.

Separated requirements into runtime (requirements.txt)
and additional development (requirements-dev.txt).
Modified devcontainer and workflow to reflect the
change.
2024-10-28 18:38:59 +00:00
Robert Alonso
f1f17d8372 refactor: add common base class to GitHubClient and LocalClient
Enables adding type checking to minimize mypy errors
2024-10-28 18:38:59 +00:00
Robert Alonso
ef72f61bed refactor: address mypy type warning 2024-10-28 18:38:59 +00:00
Robert Alonso
7435acbd70 feat: add additional Dockerfile target
Add additional, non-default, Dockerfile target
which installs app into an ubuntu image. This is
useful for local development and enables other
operations (such as committing back to the repo)
to occur within the container.
2024-10-28 18:38:59 +00:00
Robert Alonso
eefdda59f9 chore: add devcontainer 2024-10-28 18:38:59 +00:00
Robert Alonso
bd01636b00 refactor: move insert_issue_urls logic to main 2024-10-28 18:38:59 +00:00
Robert Alonso
21f86f529e feat: provide more info about issue create/update 2024-10-28 18:38:59 +00:00
Robert Alonso
a4edef676c feat: add get_issue_url()
This is really just a dummy operation so that
main can unconditionally make the call on any client
2024-10-28 18:38:59 +00:00
Robert Alonso
1fa135d86b feat: provide additional info about issue being processed 2024-10-28 18:38:59 +00:00
Robert Alonso
02c158cabe refactor: abstract diff method within client
There's no reason to have main directly construct
the URL. A different VCS (such as GitLab) could
have a different URL construction. Further, in the
case of LocalClient, there is no URL.
2024-10-28 18:38:59 +00:00
Robert Alonso
1674ad54d4 refactor: get_issue_url() returns *just* the URL
Leave the extra text to the caller (main)
2024-10-28 18:38:59 +00:00
Alastair Mooney
b9c9d197ff
Merge pull request #220 from rgalonso/fix/reset-environment-after-custom-language-tests
fix: reset modified environment variables after test
2024-10-28 09:32:00 +00:00
Alastair Mooney
2e895755ed
Merge pull request #221 from rgalonso/feat/prep-generic-vcs-support
Revert "Update main.py"
2024-10-28 09:23:27 +00:00
Robert Alonso
b1d707856d Revert "Update main.py"
This reverts commit 2157658a7d.
2024-10-25 19:17:13 +00:00
Robert Alonso
67fd1f496c fix: reset modified environment variables after test
CustomLanguageTest was modifying a few environment
variables and not restoring them when complete. This
led to problems for later tests that expected those
variables to be at their default values.
2024-10-25 18:54:29 +00:00
Alastair Mooney
22ab6506e0
Merge pull request #217 from rgalonso/feat/prep-generic-vcs-support
refactor in preparation for supporting other VCSs
2024-10-25 19:43:46 +01:00
Alastair Mooney
2157658a7d
Update main.py 2024-10-25 19:43:01 +01:00
Alastair Mooney
d6553dba69
Update TodoParser.py 2024-10-25 19:42:25 +01:00
Robert Alonso
9b24f44c63 refactor: clean up imports 2024-10-25 18:12:00 +00:00
KazumaOhashi
6d561277e7 Fix link generation for GitHub Enterprise 2024-10-25 20:25:25 +09:00
Robert Alonso
3753baeb0a fix: copy all modules into Docker image 2024-10-25 02:49:17 +00:00
Robert Alonso
c05a9e3f1a refactor: move GitHub-specific code into class
Add a new method, get_issue_url(), which returns
the VCS-specific web URL for viewing an issue.
This results in moving GitHub-specific code from
main into GitHubClient, but with no change in behavior.
2024-10-25 00:07:47 +00:00
Robert Alonso
714153eaf3 feat: add Local client
This is just a safe fallback for local testing.
If environment variables which activate the
creation of the GitHub client aren't set, then
the Local client is created. It acts on the most
recent commit of the repo in the working directory.

Minor edit to GitHubClient so that it raises an
EnvironmentError exception if INPUT_GITHUB_URL
environment variable is not defined. This allows
main to detect the error and fall back to trying
to use the Local client
2024-10-25 00:07:47 +00:00
Robert Alonso
662435d7fc refactor: split into modules
Split main.py into modules to (mostly) isolate the
GitHub-specific code from the general TODO
detection and program logic.
This is both for readability/maintainability and
to prepare for potentially supporting other
version control systems (e.g. GitLab, BitBucket).
2024-10-25 00:07:47 +00:00
Alastair Mooney
771af35191
Merge pull request #214 from aleexharris/feat/add-toml-support
Added TOML Support
2024-10-14 12:33:02 +01:00
Alex Harris
220a09bb7c test: Added tests for TOML support 2024-10-11 18:15:04 +01:00