Commit Graph

123 Commits

Author SHA1 Message Date
alstr
9a95d62451 Improve handling of block comments
Fixes #264
2025-04-04 09:43:44 +01:00
Robert Alonso
ad4d65c8b8 fix: handle CRLF and mixed line-ending files
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
2024-11-15 15:07:42 +00:00
Robert Alonso
c10ca453d9 fix: handle issue title line with trailing whitespace
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
2024-11-15 15:07:35 +00:00
Robert Alonso
2d98b5c359 fix: handle identifier with regex characters
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.
2024-11-12 16:34:09 +00:00
Robert Alonso
948c3e0507 fix: don't include source with issue URL comment
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
2024-11-12 14:28:40 +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
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
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
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
37b15115ba
Merge branch 'master' into support-ghe 2024-11-05 09:43:35 +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
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
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
Robert Alonso
b1d707856d Revert "Update main.py"
This reverts commit 2157658a7d.
2024-10-25 19:17:13 +00:00
Alastair Mooney
2157658a7d
Update main.py 2024-10-25 19:43:01 +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
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
Robin
a672421057
update main.py to avoid resource leak 2024-10-10 16:52:13 -03:00
alstr
2f462edd70 Merge master into v5 2024-09-24 14:31:16 +01:00
alstr
86193fe430 Fix issue formatting 2024-09-24 14:11:59 +01:00
alstr
81eaa8f8e3 Tidy code 2024-09-23 12:47:55 +01:00
alstr
6d4eeffd5f Add support for new projects 2024-09-20 16:16:13 +01:00
alstr
8045cef144 Link issues to PR
Closes #98
2024-09-20 12:57:24 +01:00
alstr
3e27db4be0 Add support for issue comments
Closes #123
2024-09-20 12:18:02 +01:00
alstr
28b4a92a27 Update line parsing process
Closes #90
2024-09-19 16:53:59 +01:00
alstr
da852bef15 Assign milestones by name
Closes #61
2024-09-19 13:16:29 +01:00
alstr
d67219dbb1 Insert issue URLs
Closes #199
2024-09-18 17:48:16 +01:00
alstr
f445fdb6e9 Support new reference options
Closes #123
Closes #94
2024-09-16 14:58:41 +01:00
Kevin Ge
1ff063b19e fix: check filename if no extensions match 2024-08-05 22:38:54 -07:00
alstr
e6fcedc9eb Reformat code 2024-07-11 12:39:05 +01:00
alstr
240db0f446 Remove support for classic projects
Closes #187
Closes #149
2024-06-28 13:56:27 +01:00
Aingeru
6dfbdc5f4b Corrected typo.
Signed-off-by: Aingeru <aingeru.develop@gmail.com>
2024-03-13 12:18:59 +01:00
Aingeru
e1fcaabf3b Added support for extensionless language filenames.
Signed-off-by: Aingeru <aingeru.develop@gmail.com>
2024-03-12 12:39:55 +01:00
alstr
02060fcc60 Set ace_mode for custom languages 2024-02-05 08:49:15 +00:00
alstr
aae81c5ce3 Fix case sensitivity 2024-01-08 18:58:31 +00:00
Alastair Mooney
80f1c09e2b
Merge pull request #168 from Christoph-Koschel/patch-3
Add support for custom languages
2024-01-01 09:23:04 +00:00
Christoph Koschel
493e0c4993 Fixed typo 2023-12-31 18:06:59 +01:00
alstr
7ad18c4076 Fix URL to line 2023-11-07 09:23:51 +00:00