Sha256: a42f8f973d6cf6c63da028bf22106308db84205bdf2471ef6b1bac2624c15294

Contents?: true

Size: 710 Bytes

Versions: 9

Compression:

Stored size: 710 Bytes

Contents

namespace :osm_rubocop do
  desc 'Install a pre-commit hook that ensures the code adheres to the OSM Rubocop configuration'
  task :install_precommit_hook do
    source = File.join(
      Gem.loaded_specs['osm-rubocop'].full_gem_path,
      'lib',
      'osm',
      'rubocop',
      'pre-commit.bash'
    )
    root = defined?(::Rails.root) ? ::Rails.root : Dir.pwd
    target = File.join(root, '.git', 'hooks', 'pre-commit')

    FileUtils.touch target
    FileUtils.chmod '+x', target

    source_content = File.read source
    target_content = File.read target

    unless target_content.include? source_content
      File.open(target, 'a') do |f|
        f.puts source_content
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
osm-rubocop-0.1.12 lib/tasks/osm_rubocop.rake
osm-rubocop-0.1.10 lib/tasks/osm_rubocop.rake
osm-rubocop-0.1.9 lib/tasks/osm_rubocop.rake
osm-rubocop-0.1.8 lib/tasks/osm_rubocop.rake
osm-rubocop-0.1.7 lib/tasks/osm_rubocop.rake
osm-rubocop-0.1.6 lib/tasks/osm_rubocop.rake
osm-rubocop-0.1.5 lib/tasks/osm_rubocop.rake
osm-rubocop-0.1.4 lib/tasks/osm_rubocop.rake
osm-rubocop-0.1.3 lib/tasks/osm_rubocop.rake