Skip to content

Instantly share code, notes, and snippets.

@rahulramfort
rahulramfort / pre-commit
Created August 19, 2020 16:02
Pre-commit hook - Validate Syntax for Ruby files
#!/usr/bin/env ruby
=begin
A hook to make sure that all staged .rb files are syntatically correct.
The hook tries to run `ruby -c file_path` for all those files and
prints outs the errors if any and halts the commit.
If you want to use this pre-commit, simply copy the code and create a
file called 'pre-commit' inside your .git/hooks directory.