From 2b986fe1b80874332340fe29eaeb64eea5553927 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 11 May 2025 00:49:09 +0200 Subject: [PATCH] Update shebang (#445) Co-authored-by: UltralyticsAssistant --- actions/__init__.py | 2 +- actions/update_file_headers.py | 118 ++++++++++++++++----------------- 2 files changed, 59 insertions(+), 61 deletions(-) diff --git a/actions/__init__.py b/actions/__init__.py index aa54989..32140b0 100644 --- a/actions/__init__.py +++ b/actions/__init__.py @@ -22,4 +22,4 @@ # ├── test_summarize_pr.py # └── ... -__version__ = "0.0.74" +__version__ = "0.0.75" diff --git a/actions/update_file_headers.py b/actions/update_file_headers.py index 32dee81..65ae912 100644 --- a/actions/update_file_headers.py +++ b/actions/update_file_headers.py @@ -83,72 +83,70 @@ def update_file(file_path, prefix, block_start, block_end, base_header): else: formatted_header = f"# {base_header}\n" - # Keep shebang line if it exists - start_idx = 0 - if lines and lines[0].startswith("#!"): - start_idx = 1 + # Save original content for comparison + original_content = "".join(lines) - modified = False - new_lines = lines[:start_idx] - remaining_lines = lines[start_idx:] + # Create two separate line collections: + # 1. prefix_lines: Special first line + header + blank line + # 2. content_lines: The actual file content (excluding header) + prefix_lines = [] - # If first line is already the exact header we want - if remaining_lines and remaining_lines[0] == formatted_header: - # Check if spacing is correct - new_lines.append(remaining_lines[0]) - if len(remaining_lines) > 1: - second_line = remaining_lines[1].strip() - if second_line == "" or second_line in ["#", "//", "/*", "*", "