Files
polaris-react/pre-commit
Ben Scott b2030a67cc Make pre-commit hook pass if playground is not staged
Previously the pre-commit hook stopped you commiting if you had any
changes in the playground even if those changes weren't staged for
commit. This meant you had to totally reset your playground even if you
weren't about to commit it.

Now we check if the playground is staged for commit, so if the
playground is modified but not staged for commit you can still commit
your other changes
2018-09-19 18:11:26 -07:00

31 lines
715 B
Ruby
Executable File

#!/usr/bin/ruby --disable-gems
NON_COMMITTABLE_FILE_PATHS = ['playground/Playground.tsx']
module PreCommit
extend self
def main
ignore_playground
end
private
def ignore_playground
changed_files.each do |path|
if NON_COMMITTABLE_FILE_PATHS.include? path
puts "WARNING: This commit has been aborted"
puts "Please remove changes from #{path} before committing"
puts "Or run `git update-index --assume-unchanged #{path}` to git ignore this file"
abort "Use `git commit --no-verify` to force add this file"
end
end
end
def changed_files
@changed_files ||= %x(git diff --cached --name-only HEAD).lines.map(&:chomp)
end
end
PreCommit.main