Skip to content

fix(template): put the shebang on line 1 — at the generator, not in 20 outputs - #26

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/shebang-line-1-at-the-generator
Aug 26, 2026
Merged

fix(template): put the shebang on line 1 — at the generator, not in 20 outputs#26
hyperpolymath merged 1 commit into
mainfrom
fix/shebang-line-1-at-the-generator

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

The defect

Every launcher this generator emits begins with a blank line, then the shebang — shellcheck SC2148, and a script the kernel will not dispatch by shebang.

Verified on origin across four repos (berrywiki, stapeln, gossamer, paint-type): line 1 of each <repo>-launcher.sh is empty.

Why here rather than in the twenty PRs

The estate has ~20 open one-line PRs each deleting that blank line in one generated launcher. Codacy said so on nearly every one:

the file is explicitly marked as auto-generated by launch-scaffolder; manual edits will be lost during the next launch-scaffolder realign

and stapeln#38 quantified it: 20 files identified, 1 fixed. Merging twenty downstream fixes leaves the machine that emits the defect untouched.

The first attempt was wrong, and the test caught it

Moving the shebang above a {#- … -#} block rendered as:

#!/usr/bin/env bash# SPDX-License-Identifier: MPL-2.0

— concatenated, because {#- strips whitespace before the tag and ate the newline after the shebang. A test asserting only on the template source would have passed that and shipped something worse than the original. Correct pairing is {# (don't strip before) with -#} (strip after).

Tests

test pins
template_source_opens_with_shebang the template invariant
rendered_launcher_starts_with_shebang_on_line_one renders through Tera and asserts line 1 — this is the one that caught the bad fix

Also repaired

standard::tests::baked_standard_parses was already red on origin/main: it asserted spec_version == "0.1.0" against a standard declaring 0.2.0, failing for a reason unrelated to parsing. The version is now derived from the baked source, so it cannot go stale again.

Full workspace suite: 19 passed, 0 failed (baseline on origin/main: 16 passed, 1 failed).

Follow-up

The ~20 already-generated launchers keep the blank line until a realign regenerates them. The open per-repo PRs stay valid as immediate relief; this stops reintroduction.

🤖 Generated with Claude Code

…0 outputs

Every launcher this generator emits begins with a BLANK LINE, then the shebang.
That is shellcheck SC2148 and a script the kernel will not dispatch by shebang.
Verified on origin across four repos (berrywiki, stapeln, gossamer, paint-type):
line 1 of each `<repo>-launcher.sh` is empty.

Cause: `templates/launcher.sh.tera` opened with a Tera comment block and only
then the shebang, so the rendered output carried a leading newline.

WHY THIS BELONGS HERE. The estate currently has ~20 open one-line PRs, each
deleting that blank line in one generated launcher. Codacy said so on nearly
every one of them - "the file is explicitly marked as auto-generated by
launch-scaffolder; manual edits will be lost during the next
`launch-scaffolder realign`" - and stapeln#38 quantified the gap: 20 files
identified, 1 fixed. Merging twenty downstream fixes leaves the machine that
emits the defect untouched, and the next realign overwrites all of them.

THE FIRST ATTEMPT AT THIS FIX WAS WRONG, AND THE TEST CAUGHT IT. Moving the
shebang above a `{#- ... -#}` block rendered as:

    #!/usr/bin/env bash# SPDX-License-Identifier: MPL-2.0

- concatenated, because `{#-` strips whitespace BEFORE the tag and ate the
newline after the shebang. A test asserting only on the template SOURCE would
have passed that happily and shipped a worse file than the one it replaced.
The correct pairing is `{#` (do not strip before) with `-#}` (strip after).

Two regression tests, because the property that matters is the RENDERED output:
  * template_source_opens_with_shebang - the template invariant
  * rendered_launcher_starts_with_shebang_on_line_one - renders through Tera
    and asserts line 1, which is the assertion that caught the bad fix

Also repairs a pre-existing failure that was red on origin/main before this
branch: standard::tests::baked_standard_parses asserted spec_version == "0.1.0"
against a standard declaring 0.2.0. It failed for a reason unrelated to parsing,
which is what it is named for. The version is now DERIVED from the baked source
rather than hardcoded, so it cannot go stale again.

Full workspace suite: 19 passed, 0 failed (baseline on origin/main was 16
passed, 1 failed).

Follow-up, not done here: the ~20 already-generated launchers still carry the
blank line until a `realign` regenerates them. The open per-repo PRs remain
valid as immediate relief; this stops the defect being reintroduced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e2db32e2-b250-4151-bc2e-92a4e4d04768

📥 Commits

Reviewing files that changed from the base of the PR and between 38a1341 and fe2628f.

📒 Files selected for processing (3)
  • crates/launcher-common/src/standard.rs
  • crates/launcher-common/src/template.rs
  • templates/launcher.sh.tera

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (5)
crates/launcher-common/src/standard.rs (1)

103-115: LGTM!

templates/launcher.sh.tera (1)

1-10: LGTM!

crates/launcher-common/src/template.rs (3)

149-185: LGTM!


187-201: LGTM!


203-223: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved generated launcher scripts so the Bash interpreter declaration always appears on the first line, ensuring reliable execution.
    • Standard version validation now remains aligned with the configured baked-in standard version.
  • Tests

    • Added coverage for launcher shebang placement and rendered output.
    • Strengthened validation that standard versions are present and correctly parsed.

Walkthrough

The launcher template now emits #!/usr/bin/env bash as its first line. Tests verify both baked and rendered launcher output. The baked-standard test derives the expected specification version from the source value.

Changes

Launcher validation

Layer / File(s) Summary
First-line shebang output
templates/launcher.sh.tera, crates/launcher-common/src/template.rs
The template places the Bash shebang before the Tera comment block. Tests validate the baked template and rendered launcher output.
Derived standard version assertion
crates/launcher-common/src/standard.rs
The test derives the expected version from BAKED_STANDARD and compares it with the parsed spec_version.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to fe262

This localized change fixes generated launcher shebang placement and prevents the baked standard version assertion from drifting; no actionable merge-blocking risk remains.

Poem

A rabbit checks the first-line light
Bash now starts the script just right
The template speaks, the tests agree
The standard version stays dependency-free
Hop, hop—validation is bright

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the generator-level shebang fix, the regression tests, and the stale-version test update. It is directly related to the changeset.
Title check ✅ Passed The title clearly summarises the main change: placing the shebang on line 1 in the launcher template rather than fixing generated outputs individually.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (1 skipped: 1 u…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitar-bot

gitar-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@hyperpolymath
hyperpolymath merged commit ed49cf4 into main Aug 26, 2026
17 of 18 checks passed
@hyperpolymath
hyperpolymath deleted the fix/shebang-line-1-at-the-generator branch August 26, 2026 19:20
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The implementation successfully addresses the requirement to ensure the shebang is correctly positioned on the first line of generated scripts by adjusting the Tera template and whitespace configuration. The test suite has been updated to dynamically verify the specification version, reducing the risk of regression. No security flaws or major logic bugs were identified that should prevent the PR from being merged. The overall quality metrics are within project standards, though there is one maintainability finding regarding function length in the template logic.

1 comment outside of the diff
crates/launcher-common/src/template.rs

line 27 🟡 MEDIUM RISK
The render function has grown to 99 lines, primarily due to manual Tera context population. Splitting this into logical sub-sections (e.g., project, runtime, and metadata) would improve readability and bring the function within project complexity limits.

Try running the following prompt in your IDE agent:

Refactor the render function in crates/launcher-common/src/template.rs to reduce its length. Extract the context insertion logic for 'project', 'runtime', and 'metadata' into separate private helper functions that take &mut Context and the relevant configuration structs as arguments.

Test suggestions

  • Verify that the template source code starts with the shebang string.
  • Verify that the rendered output of the template starts with the shebang on line 1 followed by a newline.
  • Verify that the baked standard parses correctly and the spec_version matches the version declared in the BAKED_STANDARD source.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

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.

1 participant