Skip to content

Commit

Permalink
improve cross-platform git check in gemspec
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
mislav committed Aug 10, 2011
1 parent 415ad49 commit af48602
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion 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|
Expand All @@ -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.