fix: scaffolded files end with single trailing newline#306
fix: scaffolded files end with single trailing newline#306ichoosetoaccept merged 1 commit intomainfrom
Conversation
- README.md.jinja: use {%- endif %} so the trailing if-block doesn't add a redundant newline
- {{_copier_conf.answers_file}}.jinja: use {{ ... -}} to strip the redundant newline after to_nice_yaml output
- .github/actionlint.yaml.jinja: tighten if/endif whitespace control to remove leading blank line
- copier.yml: exclude .github/actionlint.yaml when use_blacksmith_runners is false (no point shipping empty config)
Each scaffolded file now passes prek's end-of-file-fixer hook on first commit.
|
This change is part of the following stack:
Change managed by git-spice. |
Greptile SummaryThis PR fixes trailing-newline issues across three template files ( Confidence Score: 5/5Safe to merge — all changes are precise Jinja2 whitespace-control fixes with no logic regressions. All four changes are narrow, well-targeted whitespace fixes (strip operators and an _exclude rule) that align with Copier/Jinja2 conventions and the keep_trailing_newline: true envop. No P0 or P1 findings were identified. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[copier copy / update] --> B{use_blacksmith_runners?}
B -- false --> C[_exclude: skip actionlint.yaml generation]
B -- true --> D[Render actionlint.yaml.jinja]
D --> E["'{%- if use_blacksmith_runners -%}' strips leading + trailing newline"]
E --> F[self-hosted-runner labels content]
F --> G["'{%- endif %}' strips pre-tag newline"]
G --> H[keep_trailing_newline preserves final newline]
H --> I[actionlint.yaml: clean single trailing newline]
A --> J[Render README.md.jinja]
J --> K{use_ci and github.com?}
K -- true --> L[Branch protection section rendered]
L --> M["'{%- endif %}' strips pre-tag newline → single EOF newline"]
K -- false --> N["'{%- endif %}' strips any whitespace → single EOF newline"]
A --> O["Render answers_file.jinja"]
O --> P["{{ _copier_answers | to_nice_yaml -}}"]
P --> Q["'-}}' strips template trailing newline; to_nice_yaml provides its own newline"]
Q --> R[answers file: clean single trailing newline]
Reviews (1): Last reviewed commit: "fix: scaffolded files end with single tr..." | Re-trigger Greptile |
Summary
project/README.md.jinja,project/.github/actionlint.yaml.jinjaandproject/{{_copier_conf.answers_file}}.jinjaso the rendered files end with a single trailing newline (matchesend-of-file-fixer).actionlint.yamlfrom the scaffold whenuse_blacksmith_runnersis false.Why
Without these fixes, the
end-of-file-fixerprek hook auto-rewrites scaffolded files on the very first commit, which forces an extragit add && git commitcycle for every new project. Surfaces as part of the broader DOT-491 fresh-scaffold investigation but warrants its own PR.Test plan
poe test— greenend-of-file-fixeron first commit