feat(git): biome pre-commit hook - #1487
Conversation
blocks the commit when it finds biome issues with the changed code
Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>
b88ee6c to
a93ecdd
Compare
Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>
a93ecdd to
5b4b95b
Compare
Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>
| exit 0 | ||
| fi | ||
|
|
||
| hooks_dir=$(git config --get core.hooksPath 2>/dev/null || true) |
| mkdir -p "$(dirname "$hook_file")" | ||
|
|
||
| if [ ! -e "$hook_file" ]; then | ||
| printf '#!/bin/sh\n' >"$hook_file" |
There was a problem hiding this comment.
we should always use /bin/sh or always use /usr/bin/env sh
| mkdir -p "$(dirname "$hook_file")" | ||
|
|
||
| if [ ! -e "$hook_file" ]; then | ||
| printf '#!/bin/sh\n' >"$hook_file" |
There was a problem hiding this comment.
| printf '#!/bin/sh\n' >"$hook_file" | |
| echo "#!/bin/sh" >"$hook_file" |
| exit 0 | ||
| fi | ||
|
|
||
| printf '%s\n' "$HOOK_COMMAND" >>"$hook_file" |
There was a problem hiding this comment.
| printf '%s\n' "$HOOK_COMMAND" >>"$hook_file" | |
| echo "$HOOK_COMMAND" >>"$hook_file" |
0xda157
left a comment
There was a problem hiding this comment.
this breaks if you checkout a branch that doesn't include this PR. we should copy the script to pre-commit, not insert a script that calls it.
PepperLola
left a comment
There was a problem hiding this comment.
I left a couple comments. If the pre-commit hook is installed automatically on bun i would we want a way to disable the installation for CI? Could just be an env var we specify in the workflow file or something.
| exit 0 | ||
| fi | ||
|
|
||
| if ! xargs -0 bun x biome check --no-errors-on-unmatched --files-ignore-unknown=true <"$staged_list"; then |
There was a problem hiding this comment.
This will read the staged files from disk? In which case it's possible that someone could stage something that's formatted correctly, make a change to the file with bad formatting (but not stage) and then they'd be blocked from committing even though the staged change is okay.
This could also happen the other way around - someone stages changes with bad formatting and then runs the formatter but doesn't stage the correctly formatted files. Then they'd be allowed to commit even though the format is bad.
Task
A git hook to notify you when you try to commit something that you have a formatting error in the files that you are trying to commit. To install just
bun ish /fission/scripts/hooks/pre-committo your /.git/hooks/pre-commitTo bypass, run
git commit *--no-verify*when committingNote
Works on git worktrees only if that worktree contains the /fission/scripts/hooks/pre-commit file
Warning
Install script doesn't work on windows when using powershell and cmd. Fails cleanly
SYNTH-336
Symptom
There a quite a few
chore(formatting): ...commits right now. This PR aims to reduce the number of those.Verification
Create a formatting mistake in a file and try to commit the formatting mistake.
Before merging, ensure the following criteria are met: