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
This commit is contained in:
Robert Alonso
2024-11-12 03:38:07 +00:00
parent ff0c64d51e
commit 948c3e0507
4 changed files with 22 additions and 15 deletions

View File

@@ -78,7 +78,7 @@ def process_diff(diff, client=Client(), insert_issue_urls=False, parser=TodoPars
old_line = file_lines[line_number]
remove = fr'(?i:{raw_issue.identifier}).*{re.escape(raw_issue.title)}'
insert = f'Issue URL: {client.get_issue_url(new_issue_number)}'
new_line = re.sub(remove, insert, old_line)
new_line = re.sub('^.*'+remove, raw_issue.prefix + insert, old_line)
# make sure the above operation worked as intended
if new_line != old_line:
# Check if the URL line already exists, if so abort.