Skip to content

Instantly share code, notes, and snippets.

View fhwang's full-sized avatar

Francis Hwang fhwang

View GitHub Profile
@kch
kch / modsux.rb
Created November 3, 2009 22:27
Assimilates git submodules' files, gets properly rid of the submodule metadata.
#!/usr/bin/env ruby
require 'yaml'
require 'pathname'
require 'shellwords'
module_url_by_path = Dir['**/.gitmodules'].inject({}) do |h, path|
IO.read(path).scan(/^\[submodule .*\].*\n((?:\s+.*\n)+)/).flatten.each do |s_attrs|
h_attrs = s_attrs.strip.split(/\n/).inject({}) do |h_attrs, s_attr_line|
k, v = s_attr_line.strip.split(/\s+=\s+/, 2)
h_attrs[k.to_sym] = v