2016-09-22 19:04:35 +02:00
|
|
|
# frozen_string_literal: true
|
2016-02-23 17:44:16 +02:00
|
|
|
require "bundler"
|
2015-10-02 18:14:19 -03:00
|
|
|
require "bundler/gem_tasks"
|
2015-04-02 12:05:26 +03:00
|
|
|
require "rubocop/rake_task"
|
|
|
|
require "rspec/core/rake_task"
|
2015-10-02 18:14:19 -03:00
|
|
|
require "pathname"
|
|
|
|
require "fileutils"
|
2016-02-23 12:38:27 +02:00
|
|
|
require "overcommit"
|
2014-12-03 11:30:26 +02:00
|
|
|
|
2015-03-26 15:33:56 +02:00
|
|
|
RuboCop::RakeTask.new
|
|
|
|
RSpec::Core::RakeTask.new(:rspec)
|
|
|
|
|
2016-02-25 20:13:32 +01:00
|
|
|
task :copy_man_page_to_manpath do |_t|
|
|
|
|
known_manpath_paths = %w(/etc/manpath.config /etc/manpaths)
|
|
|
|
manpath = known_manpath_paths.find do |f|
|
|
|
|
path = Pathname(f)
|
|
|
|
path.file? && path.readable?
|
|
|
|
end
|
|
|
|
|
2016-02-28 22:13:23 +01:00
|
|
|
next unless manpath
|
2016-02-25 20:13:32 +01:00
|
|
|
|
|
|
|
writable_man_path = Pathname(manpath).each_line.find do |line|
|
2016-02-25 19:56:25 +01:00
|
|
|
path = Pathname(line.chomp)
|
|
|
|
path.directory? && path.writable?
|
2016-02-25 20:13:32 +01:00
|
|
|
end
|
2016-02-25 19:56:25 +01:00
|
|
|
|
2016-02-28 22:13:23 +01:00
|
|
|
next unless writable_man_path
|
2016-02-25 19:56:25 +01:00
|
|
|
|
|
|
|
man_prefix = Pathname("#{writable_man_path.chomp}/man1")
|
2016-02-25 19:14:44 +01:00
|
|
|
man_pages = "man/git-*.1"
|
2015-10-02 18:14:19 -03:00
|
|
|
|
|
|
|
Pathname.glob(man_pages) do |path|
|
2016-02-25 19:22:34 +01:00
|
|
|
if path.exist? && man_prefix.exist? && man_prefix.writable?
|
2016-02-25 19:14:44 +01:00
|
|
|
FileUtils.cp(path, man_prefix + path.basename)
|
|
|
|
end
|
2015-10-02 18:14:19 -03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task checks: [:rubocop, :rspec]
|
2016-09-22 18:20:58 +02:00
|
|
|
task default: [:rubocop, :rspec]
|