From 107772e562b51d3e355925a55714d566fe484c88 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Mon, 27 Nov 2017 23:49:56 +0000 Subject: [PATCH] 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) --- lib/bundler/templates/newgem/newgem.gemspec.tt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt index 1236bb1bd70..97da2b14d81 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) }