Arkweid
(Abroskin Alexander)
July 2, 2019, 9:46pm
1
Hello, guys. Lefthook was merged in dev environment. I’m author so that I can help with any question about it. If anyone faced with issues or wants a feature, let me know
6 Likes
pfaffman
(Jay Pfaffman)
July 2, 2019, 9:58pm
2
Welcome, @Arkweid ! Can you say more about what Lefthook is and why we’d want to know more about it? Maybe a link to it and a use case?
2 Likes
Falco
(Falco)
July 2, 2019, 10:20pm
3
I used it for the first time today, and it’s great that I had to do zero setup in my machine for it.
Thanks for the pull request!
There is context here:
discourse:master
← Arkweid:replace-overcommit-with-lefthook
opened 04:41PM - 28 Jun 19 UTC
Overcommit uses prebuilt hooks and require global installation.
To avoid this i… ssues replace it with [Lefthook](https://github.com/Arkweid/lefthook).
Lefthook will be installed with npm packages. New contributors
will have fully consistent git hooks.
Goals:
- **Strict workflow**. Avoid situations when newcomers pushed PR without checks with rubocop or eslint. And members should [recommend](https://github.com/discourse/discourse/pull/7192#issuecomment-473973502) to install overcommit.
- **Flexibility**. You free to combine basic operations.
- **Сlarification**. Overcommit provide prebuilt hooks. So its hard to understend what is going on without inspecting overcommit repository.
- **20% Faster**. Well, it not a big issue in development environment, but a like faster instruments :)
- **Twice speed up for CI lints**. With Lefthook we can run lints on CI in paralel mode. You can check [example here](https://travis-ci.org/discourse/discourse/jobs/551862476#L956).
Example output for this commit:
![PR example](https://i.gyazo.com/1eb2d11850b1a826981bec7375527501.png "PR example")
Example output for CI lints:
![PR example](https://i.gyazo.com/c5e2c92383437d3617bc138e28e74a01.png "PR example")
Don't forget to remove preinstalled hooks from you repo `overcommit --uninstall` if you want to test it action.
So what do you think about. Is it worth?
4 Likes
Arkweid
(Abroskin Alexander)
July 2, 2019, 11:00pm
4
Here is a repo.
Lefthook is a Git hooks manager. It written in Go, so it just a single binary without dependencies and you can use it in any type of project(Rust, Erlang, Java anything you want).
Addtional features you may be interested in Discourse context:
Run script files - Lefthook can run not only oneline commands. Here example how to check commit header and decline it if pattern not matched. No fix bug
commits anymore!
Integrate with crystalball - it always nice to run rspec tests only for changed code. It easy with Lefthook.
4 Likes
Arkweid
(Abroskin Alexander)
July 10, 2019, 4:15pm
5
Guide about have to use Lefthook + Crystallball .
If someone are tired of waiting rspec
for 10 minutes and want to run actual tests for changed code