Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save initdc/af23b51fe90630cc0e764772a881a578 to your computer and use it in GitHub Desktop.

Select an option

Save initdc/af23b51fe90630cc0e764772a881a578 to your computer and use it in GitHub Desktop.
Gem Spec support for git submodules inside a gem.
Gem::Specification.new do |s|
# normal spec stuff above
s.files = `git ls-files`.split("\n")
# get an array of submodule dirs by executing 'pwd' inside each submodule
gem_dir = File.expand_path(File.dirname(__FILE__)) + "/"
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
Dir.chdir(submodule_path) do
submodule_relative_path = submodule_path.sub gem_dir, ""
# issue git ls-files in submodule's directory and
# prepend the submodule path to create absolute file paths
`git ls-files`.split($\).each do |filename|
s.files << "#{submodule_relative_path}/#{filename}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment