mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-22 22:06:43 +00:00
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
This commit is contained in:
parent
5157ba918f
commit
c10ca453d9
@ -547,7 +547,7 @@ class TodoParser(object):
|
||||
comment = comment.strip()
|
||||
pre_marker_length = original_comment.find(comment)
|
||||
else:
|
||||
comment_segments = re.search(fr'^(.*?)({marker["pattern"]})(\s*)(.*)', comment)
|
||||
comment_segments = re.search(fr'^(.*?)({marker["pattern"]})(\s*)(.*?)\s*$', comment)
|
||||
if comment_segments:
|
||||
pre_marker_text, _, post_marker_whitespace, comment = comment_segments.groups()
|
||||
pre_marker_length = len(pre_marker_text)
|
||||
|
||||
2
main.py
2
main.py
@ -76,7 +76,7 @@ def process_diff(diff, client=Client(), insert_issue_urls=False, parser=TodoPars
|
||||
if line_number < len(file_lines):
|
||||
# Duplicate the line to retain the comment syntax.
|
||||
old_line = file_lines[line_number]
|
||||
remove = fr'(?i:{re.escape(raw_issue.identifier)}).*{re.escape(raw_issue.title)}'
|
||||
remove = fr'(?i:{re.escape(raw_issue.identifier)}).*{re.escape(raw_issue.title)}.*?(\r|\r\n|\n)?$'
|
||||
insert = f'Issue URL: {client.get_issue_url(new_issue_number)}'
|
||||
new_line = re.sub('^.*'+remove, raw_issue.prefix + insert, old_line)
|
||||
# make sure the above operation worked as intended
|
||||
|
||||
Loading…
Reference in New Issue
Block a user