Skip to content

fix: put generated pre-commit shebang first#236

Merged
dpc merged 1 commit into
rustshop:masterfrom
dpc:dpc/jj-smmxkqmzyrxw
Jul 9, 2026
Merged

fix: put generated pre-commit shebang first#236
dpc merged 1 commit into
rustshop:masterfrom
dpc:dpc/jj-smmxkqmzyrxw

Conversation

@dpc

@dpc dpc commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

PR published by Tau

Summary

Fix generated git pre-commit hooks so their bash shebang is on line 1. This prevents direct hook execution from falling back to /bin/sh on systems where /bin/sh is not bash.

Details

The generated pre-commit hook now keeps the flakebox banner below the hook head/shebang. A regression check verifies generated pre-commit and commit-msg hooks have line-1 shebangs and pass bash -n.

Comment thread misc/git-hooks/pre-commit Outdated
}
export -f check_nothing

#

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a wrong place? This should have been under shebang, but otherwise on top.

@dpc dpc force-pushed the dpc/jj-smmxkqmzyrxw branch 2 times, most recently from 5f4869e to 7ddce22 Compare July 9, 2026 18:28
### Summary

Fix flakebox pre-commit hook generation so generated `misc/git-hooks/pre-commit` starts with the intended bash shebang on line 1, followed immediately by the flakebox generated-file banner. This prevents direct execution from falling back to `/bin/sh` on systems that honor only a first-line shebang, while keeping the banner at the top of the generated file.

### Details

The pre-commit generator now owns the executable script prologue: it emits `#!/usr/bin/env bash`, then the generated-file banner, then includes the reusable hook body fragment. The former `pre-commit.head.sh` fragment was renamed to `pre-commit.body.bash` and no longer carries its own shebang, making it clear that it is not a standalone script. The `gitHooks` regression check builds the generated root, asserts the first line of both generated git hooks is `#!/usr/bin/env bash`, asserts the pre-commit banner immediately follows the shebang, and runs `bash -n` on the generated hooks. Regenerated the checked-in pre-commit hook and root id. Validation and independent review passed.
@dpc dpc force-pushed the dpc/jj-smmxkqmzyrxw branch from 7ddce22 to 3436f22 Compare July 9, 2026 18:31
@dpc dpc merged commit b9185ae into rustshop:master Jul 9, 2026
4 checks passed
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