This repository has been archived on 2021-01-10. You can view files and clone it, but cannot push or open issues or pull requests.
custom-nix/blog/submodule-links.rb

20 lines
626 B
Ruby

puts "[params]"
puts " [params.submoduleLinks]"
`git submodule status --recursive`.lines do |line|
hash, path = line[1..].split " "
next unless path.start_with? "code/"
code_path = path.delete_prefix "code/"
url = `git config --file .gitmodules --get 'submodule.#{path}.url'`.chomp.delete_suffix(".git")
safe_name = code_path.gsub(/\/|-|_/, "")
if url =~ /dev.danilafe.com/
file_url = "#{url}/src/commit/#{hash}"
else
raise "Submodule URL not in a known format!"
end
puts " [params.submoduleLinks.#{safe_name}]"
puts " path = #{code_path.dump}"
puts " url = #{file_url.dump}"
end