mirror of
https://github.com/HackPlan/polaris-react.git
synced 2026-01-12 22:44:36 +08:00
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
31 lines
715 B
Ruby
Executable File
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
|