Skip to content

fix: strip leading blank lines before license insertion#110

Draft
Wheest wants to merge 1 commit intoLucas-C:masterfrom
Wheest:master
Draft

fix: strip leading blank lines before license insertion#110
Wheest wants to merge 1 commit intoLucas-C:masterfrom
Wheest:master

Conversation

@Wheest
Copy link
Copy Markdown

@Wheest Wheest commented Apr 10, 2026

Note: Not ready for review yet - still considering if this is the right approach and does what we want.

Summary

Fixes #107

When a file starts with blank lines, the license is currently inserted after them rather than at line 1. This causes issues when combined with formatters like buildifier that sort statements to the top of files.

Changes

  • Leading blank lines (before any content) are now stripped
  • Blank lines after shebang/encoding directives are preserved
  • License is inserted at the correct position

Test plan

  • Added 3 new test cases for the bug scenarios
  • All 549 tests pass

Previously, when a file started with blank lines, the license would be
inserted after them rather than at line 1. This caused issues when
combined with formatters that sort statements to the top of files.

The fix:
- Leading blank lines (before any content) are now stripped
- Blank lines after shebang/encoding directives are preserved
- License is inserted at the correct position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insert license and top-of-file whitespace

1 participant