Skip to content

Commit

Permalink
Ensure git is executed inside the gemspec dir
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
elia committed Nov 28, 2017
1 parent 914a4a8 commit 107772e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/bundler/templates/newgem/newgem.gemspec.tt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit 107772e

Please sign in to comment.