add pre-commit-check #1369

Merged
Qubasa merged 2 commits from fricklerhandwerk/clan-core:add-pre-commit into main 2024-05-22 11:49:57 +00:00
Collaborator

make sure things are sane before they hit CI.
this re-purposes the existing treefmt configuration.

make sure things are sane before they hit CI. this re-purposes the existing treefmt configuration.
fricklerhandwerk added 1 commit 2024-05-15 15:10:04 +00:00
add pre-commit check
All checks were successful
checks / check-links (pull_request) Successful in 14s
checks / checks-impure (pull_request) Successful in 2m28s
checks / checks (pull_request) Successful in 4m35s
6bfc6c977a
make sure things are sane before they hit CI.
this re-purposes the existing treefmt configuration.
fricklerhandwerk requested review from Mic92 2024-05-15 15:10:28 +00:00
fricklerhandwerk requested review from Qubasa 2024-05-15 15:10:28 +00:00
fricklerhandwerk requested review from hsjobeki 2024-05-15 15:10:28 +00:00
Author
Collaborator

Hm, upon further inspection I realized that git-hooks.nix is a Rube Goldberg machine on top of pre-commit, which is a Rube Goldberg machine on top of almost literally running treefmt as a pre-commit hook.

Hm, upon further inspection I realized that [git-hooks.nix](https://github.com/cachix/git-hooks.nix) is a Rube Goldberg machine on top of [pre-commit](https://github.com/pre-commit/pre-commit), which is a Rube Goldberg machine on top of [almost literally running treefmt as a pre-commit hook](https://git.clan.lol/clan/clan-core/src/commit/930923512c03179fe75e4209c27eb3da368e7766/scripts/pre-commit).
Owner

We initially had pre commit checks but found it to break programs like lazygit and be generally too slow. Sometimes you just want to commit a partial unfinished result :-)

We initially had pre commit checks but found it to break programs like lazygit and be generally too slow. Sometimes you just want to commit a partial unfinished result :-)
Qubasa closed this pull request 2024-05-21 12:20:38 +00:00
Author
Collaborator

@Qubasa hm, I'm developing this on a 2012 Thinkpad and don't even notice the difference. treefmt is pretty fast. You can run git commit --no-verify to skip the hook.

I'd ask to reconsider this, since the overall turnaround is significantly reduced if one doesn't have to wait for and poll CI to notice that there's a formatting error.

Edit: Slowness in the past may have come from the hook running nix fmt, which would probably have evaluated some large expression before doing any work. With the proposed setup, treefmt is run pretty much directly. Check https://github.com/fricklerhandwerk/git-hooks/ for detailed documentation.

@Qubasa hm, I'm developing this on a 2012 Thinkpad and don't even notice the difference. `treefmt` is pretty fast. You can run `git commit --no-verify` to skip the hook. I'd ask to reconsider this, since the overall turnaround is significantly *reduced* if one doesn't have to wait for and poll CI to notice that there's a formatting error. Edit: Slowness in the past may have come from the hook running `nix fmt`, which would probably have evaluated some large expression before doing any work. With the proposed setup, `treefmt` is run pretty much directly. Check https://github.com/fricklerhandwerk/git-hooks/ for detailed documentation.
fricklerhandwerk reopened this pull request 2024-05-22 09:37:39 +00:00
fricklerhandwerk force-pushed add-pre-commit from f6a32f3f04 to 02a9390218 2024-05-22 09:38:18 +00:00 Compare
fricklerhandwerk force-pushed add-pre-commit from 02a9390218 to 81757051f5 2024-05-22 11:38:25 +00:00 Compare
Owner

@fricklerhandwerk Ahh I just tested it. It's really fast! Awesome :D

@fricklerhandwerk Ahh I just tested it. It's really fast! Awesome :D
Qubasa merged commit acaa69e2bf into main 2024-05-22 11:49:57 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: clan/clan-core#1369
No description provided.