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:
Robert Alonso
2024-11-14 20:40:49 +00:00
parent 5157ba918f
commit c10ca453d9
2 changed files with 2 additions and 2 deletions

View File

@@ -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