From 772e403e40d7d7e2c34e3c0a8d9f51ec589fb01a Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 25 Feb 2016 19:14:44 +0100 Subject: [PATCH 1/6] Man page copying: only copy .1 - check if possible first --- Rakefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 6e525a6..6922c31 100644 --- a/Rakefile +++ b/Rakefile @@ -12,10 +12,12 @@ RSpec::Core::RakeTask.new(:rspec) task :create_man do |_t| os_prefix = "/usr/local" man_prefix = Pathname("#{os_prefix}/share/man/man1") - man_pages = "man/git-*" + man_pages = "man/git-*.1" Pathname.glob(man_pages) do |path| - FileUtils.cp(path, man_prefix + path.basename) + if path.exist? && man_prefix.exist? + FileUtils.cp(path, man_prefix + path.basename) + end end end From 5bc90a32aeac9bb669b5cb105c1d40d55ab41532 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 25 Feb 2016 19:22:34 +0100 Subject: [PATCH 2/6] Check if man path is writable before writing --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 6922c31..3d33796 100644 --- a/Rakefile +++ b/Rakefile @@ -15,7 +15,7 @@ task :create_man do |_t| man_pages = "man/git-*.1" Pathname.glob(man_pages) do |path| - if path.exist? && man_prefix.exist? + if path.exist? && man_prefix.exist? && man_prefix.writable? FileUtils.cp(path, man_prefix + path.basename) end end From c1114883764f59046311e227f3b16744e2bd2eb3 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 25 Feb 2016 19:56:25 +0100 Subject: [PATCH 3/6] Look in /etc/manpaths for writable paths --- Rakefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 3d33796..4a8e9a8 100644 --- a/Rakefile +++ b/Rakefile @@ -10,8 +10,14 @@ RuboCop::RakeTask.new RSpec::Core::RakeTask.new(:rspec) task :create_man do |_t| - os_prefix = "/usr/local" - man_prefix = Pathname("#{os_prefix}/share/man/man1") + writable_man_path = Pathname('/etc/manpaths').each_line.find do |line| + path = Pathname(line.chomp) + path.directory? && path.writable? + end rescue nil + + return unless writable_man_path + + man_prefix = Pathname("#{writable_man_path.chomp}/man1") man_pages = "man/git-*.1" Pathname.glob(man_pages) do |path| From 159173d86ac79235db7fb856dde24e0e7c2c8d01 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 25 Feb 2016 20:13:32 +0100 Subject: [PATCH 4/6] Rake task: Try finding a writable manpath - OS X, Ubuntu manpath files checked --- Rakefile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index 4a8e9a8..90a7c1c 100644 --- a/Rakefile +++ b/Rakefile @@ -9,11 +9,19 @@ require "overcommit" RuboCop::RakeTask.new RSpec::Core::RakeTask.new(:rspec) -task :create_man do |_t| - writable_man_path = Pathname('/etc/manpaths').each_line.find do |line| +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 + + return unless manpath + + writable_man_path = Pathname(manpath).each_line.find do |line| path = Pathname(line.chomp) path.directory? && path.writable? - end rescue nil + end return unless writable_man_path @@ -28,4 +36,4 @@ task :create_man do |_t| end task checks: [:rubocop, :rspec] -task default: [:create_man] +task default: [:copy_man_page_to_manpath] From 08cacdc5eca37104c54158b72c32bf9b091093ea Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 25 Feb 2016 20:26:03 +0100 Subject: [PATCH 5/6] Gemfile now with test deps, too --- Gemfile | 4 ++++ Gemfile.lock | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 0724b52..093f773 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,10 @@ source "https://rubygems.org" gemspec group :test do + gem "rake" + gem "bundler" + gem "rubocop" + gem "overcommit" gem "coveralls", "~>0.8", require: false gem "simplecov", "~>0.10", require: false gem "codeclimate-test-reporter", "~>0.4" diff --git a/Gemfile.lock b/Gemfile.lock index f3502b0..e2fa964 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - github_changelog_generator (1.11.2) + github_changelog_generator (1.11.3) bundler (>= 1.7) colorize (~> 0.7) github_api (~> 0.12) @@ -98,9 +98,13 @@ PLATFORMS ruby DEPENDENCIES + bundler codeclimate-test-reporter (~> 0.4) coveralls (~> 0.8) github_changelog_generator! + overcommit + rake + rubocop simplecov (~> 0.10) BUNDLED WITH From 9b7273f009fa422778d5ff5304dda2b1aa260cea Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 25 Feb 2016 20:29:01 +0100 Subject: [PATCH 6/6] Rake task: enable the default task again --- github_changelog_generator.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github_changelog_generator.gemspec b/github_changelog_generator.gemspec index a7922b4..a8ad97a 100644 --- a/github_changelog_generator.gemspec +++ b/github_changelog_generator.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.description = "Changelog generation has never been so easy. Fully automate changelog generation - this gem generate change log file based on tags, issues and merged pull requests from Github issue tracker." spec.homepage = "https://github.com/skywinder/Github-Changelog-Generator" spec.license = "MIT" - #spec.extensions = ["Rakefile"] + spec.extensions = ["Rakefile"] spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }