From cbad3b76eb102d6e84bc9ff7f371f6cbcfe56e63 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 10 Jan 2021 20:24:22 -0800 Subject: [PATCH] Add script to generate submodule links. --- submodule-links.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 submodule-links.rb diff --git a/submodule-links.rb b/submodule-links.rb new file mode 100644 index 0000000..5bc5bb8 --- /dev/null +++ b/submodule-links.rb @@ -0,0 +1,19 @@ +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