From af486027959495c9f05d224c246f569a26b71071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohnic=CC=81?= Date: Wed, 10 Aug 2011 16:54:50 +0200 Subject: [PATCH] improve cross-platform git check in gemspec [ci skip] --- will_paginate.gemspec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/will_paginate.gemspec b/will_paginate.gemspec index 68ec5ee00..e70a9d539 100644 --- a/will_paginate.gemspec +++ b/will_paginate.gemspec @@ -1,4 +1,5 @@ # encoding: utf-8 +require 'rbconfig' require File.expand_path('../lib/will_paginate/version', __FILE__) Gem::Specification.new do |s| @@ -16,5 +17,13 @@ Gem::Specification.new do |s| s.extra_rdoc_files = ['README.md', 'LICENSE'] s.files = Dir['Rakefile', '{bin,lib,test,spec}/**/*', 'README*', 'LICENSE*'] - s.files &= `git ls-files -z`.split("\0") if `type -t git 2>/dev/null || which git 2>/dev/null` && $?.success? + + # include only files in version control + git_dir = File.expand_path('../.git', __FILE__) + void = defined?(File::NULL) ? File::NULL : + RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null' + + if File.directory?(git_dir) and system "git --version >>#{void} 2>&1" + s.files &= `git --git-dir='#{git_dir}' ls-files -z`.split("\0") + end end