Permalink
Browse files

improve cross-platform git check in gemspec

[ci skip]
  • Loading branch information...
1 parent 415ad49 commit af486027959495c9f05d224c246f569a26b71071 @mislav mislav committed Aug 10, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 will_paginate.gemspec
View
@@ -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

0 comments on commit af48602

Please sign in to comment.