Hacker News new | past | comments | ask | show | jobs | submit login

It's 95% there, but English is hard… We can be helpful about it so the authors can fix it.

¶1: Meet Lefthook, the fastest polyglot Git hooks manager out there. It ensures not a single line of unruly code makes it into production. See how easy it is to install Leftook, which was recently adopted by Discourse, Logux, and Openstax. Lefthook works with the most common front-end and back-end environments so all the developers on your team can rely on a single, flexible tool. And it also has emojis

¶2: The days when a single piece of software that millions rely on was created by a single developer in an ivory tower are long gone. Even Git, universally believed to be the brainchild of Linus Torvalds alone, was created with the help of contributors and is now being maintained by a team of dozens.

¶3: No matter if you work on an open-source project with the whole world as your oyster, or your code blooms in a walled garden of proprietary software—you still work as a team. And even with a well-organized system of pull requests and code reviews, maintaining the code quality across the large codebase with dozens of contributors is not an easy task.

¶4: Hooks—ways to fire off custom scripts when certain important actions (commit, push, etc.) occur—are baked right into Git, so if you are comfortable with Bash and the internals of the world's most popular version control system, you don’t need any external tools: just edit ./.git/hooks/pre-commit and put in some well-formed script that will, for instance, lint your files before you commit.

¶5: However, when you work on a project you are most interested in writing the project’s code, not the code that checks it. In the world of modern web development, tooling is everything, and a myriad of tools exist for a single reason: reducing overhead and complexity. Git hooks are no exception: in JavaScript community, the weapon of choice is Husky with Webpack, Babel, and create-react-app relying on this Node-based tool; the Rails-centric backend world however is mostly ruled by Overcommit that comes as a Ruby gem.

¶6: Both tools are excellent in their regard, but in a mixed team of front-end and back-end developers, as Evil Martians are, you will often end up having two separate setups for Ruby and JavaScript with front-enders and back-enders linting their commits each in their way.

¶7: With Lefthook, you don’t need to think twice—it’s a single Go binary that has wrappers both for JavaScript and for Ruby. It can also be used as a standalone tool for any other environment.

¶8: Using Go makes Lefthook lightning-fast and provides support for concurrently executed scripts out of the box. The fact that the executable is a single machine-code binary also removes the need for handling external dependencies. (Husky + lint-staged add roughly 1500 dependencies to your node_modules.) It also removes the headache of reinstalling dependencies after each update of your development environment. (Try running a globally-installed Ruby gem with another version of Ruby!)

¶9: With Lefthook added in either package.json or Gemfile and a lefthook.yml configured in the project’s root (see examples below), the tool will be installed and used against your code automatically on the next git pull, yarn install/bundle install or git add/git commit. All with zero overhead for new contributors.

¶10: An extensive README describes all the possible usage scenarios for Lefthook. Its straightforward configuration syntax does not hide actual commands being run by Lefthook, making sure there's no funny business going on.

¶11: Discourse—an incredibly popular open-source platform for forum-style discussions—has recently transitioned from Overcommit to Lefthook and never looked back. With almost 700 contributors authoring 34K commits and counting, running linters on all new contributions is a priority. With Overcommit though, team members constantly had to remind newcomers to install required tools.

¶12: Now that @arkweid/lefthook is a dev dependency in the project’s package.json, no setup is necessary for new contributors.

§1: Lefthook halves the time that pre-commit scripts take on localhost.

¶13: The PR that changed the Git hook manager simply required changing .overcommit.yml to lefthook.yml. If you compare them, you will see that Lefthook’s configuration is much more explicit while the Overcommit’s relies mostly on the magic of plugins.

¶14: Besides changing the way the output looks, Lefthook offers a nice summary of everything it does. Lefthook halves the time that pre-commit scripts take on localhost, and increases the CI run speed by 20% (on CI environments with better support for parallel execution, the gain can be considerably more).




Hey! One of co-authors here. Thanks for the editing work, I will definitely take it into consideration, minus the loss of boxing references :)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: