Sha256: c772917a4423e10ccd44e6225ebf9b0c9d4a2ed382d38655bbcecaf2f1afd9a1
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
module PreCommit class CiCheck CI_TASK_NAME = 'pre_commit:ci' def call if rakefile_present? && has_ci_task? run else $stderr.puts "pre-commit: skipping ci check. The `#{CI_TASK_NAME}` task is not defined." # pretend the check passed and move on true end end def run if tests_passed? true else $stderr.puts 'pre-commit: your test suite has failed' $stderr.puts "for the full output run `#{CI_TASK_NAME}`" $stderr.puts false end end def tests_passed? system("rake #{CI_TASK_NAME} --silent") end def rakefile_present? ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].any? do |file| File.exist?(file) end end def has_ci_task? require 'rake' Rake.application.init Rake.application.load_rakefile Rake::Task.task_defined?(CI_TASK_NAME) rescue LoadError $stderr.puts 'pre-commit: rake not found, skipping ci check' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pre-commit-0.8.1 | lib/pre-commit/checks/ci_check.rb |
pre-commit-0.8.0 | lib/pre-commit/checks/ci_check.rb |
pre-commit-0.7.0 | lib/pre-commit/checks/ci_check.rb |