feat: pre-commit hook for fmt#595
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Deploying blockfrost-platform with
|
| Latest commit: |
d90cc41
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6c65ed56.blockfrost-platform.pages.dev |
| Branch Preview URL: | https://fmt-clippy-precommit.blockfrost-platform.pages.dev |
| startup.install-git-hooks.text = '' | ||
| # Point git at our version-controlled hooks (currently: pre-commit fmt check). | ||
| if [[ -e "$PRJ_ROOT/.git" ]] ; then | ||
| git -C "$PRJ_ROOT" config core.hooksPath .githooks |
There was a problem hiding this comment.
Maybe add || true, in case .git is read-only?
There was a problem hiding this comment.
Pull request overview
Adds an auto-installed Git pre-commit hook via the Nix devshell so contributors get formatting (treefmt) enforced at commit time.
Changes:
- Introduces a devshell startup step that configures
core.hooksPathfor the repo. - Adds a generated
pre-commithook that runs the flake formatter with--fail-on-change, with an opt-out viaSKIP_TREEFMT.
| if [[ -e "$PRJ_ROOT/.git" ]] ; then | ||
| # Don't abort devshell startup if .git is read-only | ||
| git -C "$PRJ_ROOT" config --local core.hooksPath ${gitHooks} || true | ||
| fi |
There was a problem hiding this comment.
If it already is equal to gitHooks why would we set it to the same value?
The issue is we want it updated after the /nix/store hash of the gitHooks changes
There was a problem hiding this comment.
We could match /nix/store/*-blockfrost-platform-git-hooks instead.
…n of our own hooks
michalrus
left a comment
There was a problem hiding this comment.
LGTM – I tested it, and it works
| if [[ -e "$PRJ_ROOT/.git" ]] ; then | ||
| # Don't abort devshell startup if .git is read-only | ||
| git -C "$PRJ_ROOT" config --local core.hooksPath ${gitHooks} || true | ||
| fi |
There was a problem hiding this comment.
If it already is equal to gitHooks why would we set it to the same value?
The issue is we want it updated after the /nix/store hash of the gitHooks changes
| if [[ -e "$PRJ_ROOT/.git" ]] ; then | ||
| # Don't abort devshell startup if .git is read-only | ||
| git -C "$PRJ_ROOT" config --local core.hooksPath ${gitHooks} || true | ||
| fi |
There was a problem hiding this comment.
We could match /nix/store/*-blockfrost-platform-git-hooks instead.
| if [[ -e "$PRJ_ROOT/.git" ]] ; then | ||
| # Don't abort devshell startup if .git is read-only | ||
| git -C "$PRJ_ROOT" config --local core.hooksPath ${gitHooks} || true | ||
| fi |
No description provided.