mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-22 22:06:43 +00:00
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
This commit is contained in:
parent
efb8b9830d
commit
d81fdc509c
2
main.py
2
main.py
@ -79,7 +79,7 @@ if __name__ == "__main__":
|
||||
insert_issue_urls = os.getenv('INPUT_INSERT_ISSUE_URLS', 'false') == 'true'
|
||||
|
||||
# Cycle through the Issue objects and create or close a corresponding GitHub issue for each.
|
||||
for j, raw_issue in enumerate(issues_to_process):
|
||||
for j, raw_issue in enumerate(sorted(reversed(sorted(issues_to_process, key = operator.attrgetter('start_line'))), key = operator.attrgetter('file_name'))):
|
||||
print(f"Processing issue {j + 1} of {len(issues_to_process)}: '{raw_issue.title}' @ {raw_issue.file_name}:{raw_issue.start_line}")
|
||||
if raw_issue.status == LineStatus.ADDED:
|
||||
status_code, new_issue_number = client.create_issue(raw_issue)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user