summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElia Schito <elia@schito.me>2017-11-27 23:49:56 +0000
committerElia Schito <elia@schito.me>2017-11-28 10:43:16 +0100
commit107772e562b51d3e355925a55714d566fe484c88 (patch)
tree217e34a4b0b6629f99f3654725613e7fb58b0c83
parent914a4a8b8d0cf1a79dbc7b334fbb5c2db1ecdc16 (diff)
downloadbundler-107772e562b51d3e355925a55714d566fe484c88.tar.gz
Ensure git is executed inside the gemspec dir
When a Gemfile was pointing to a local gem using git to list its files the git command was executed from within the wrong dir. This fixes the issue without: 1. introducing new dependencies (e.g. `shellwords`) 2. any risks with non-trivial paths (e.g. paths containing spaces)
-rw-r--r--lib/bundler/templates/newgem/newgem.gemspec.tt4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt
index 1236bb1bd7..97da2b14d8 100644
--- a/lib/bundler/templates/newgem/newgem.gemspec.tt
+++ b/lib/bundler/templates/newgem/newgem.gemspec.tt
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
"public gem pushes."
end
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
- f.match(%r{^(test|spec|features)/})
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }