Switch to using data/ for submodule information

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-05-16 15:38:59 -07:00
parent 60d3b3025a
commit a29bca499f
4 changed files with 14 additions and 25 deletions

View File

@ -1,17 +0,0 @@
[params]
[params.submoduleLinks]
[params.submoduleLinks.agdaspa]
url = "https://dev.danilafe.com/DanilaFe/agda-spa/src/commit/f0da9a902005b24db4e03a89c2862493735467c4"
path = "agda-spa"
[params.submoduleLinks.aoc2020]
url = "https://dev.danilafe.com/Advent-of-Code/AdventOfCode-2020/src/commit/7a8503c3fe1aa7e624e4d8672aa9b56d24b4ba82"
path = "aoc-2020"
[params.submoduleLinks.blogstaticflake]
url = "https://dev.danilafe.com/Nix-Configs/blog-static-flake/src/commit/67b47d9c298e7476c2ca211aac5c5fd961637b7b"
path = "blog-static-flake"
[params.submoduleLinks.compiler]
url = "https://dev.danilafe.com/DanilaFe/bloglang/src/commit/137455b0f4365ba3fd11c45ce49781cdbe829ec3"
path = "compiler"
[params.submoduleLinks.serverconfig]
url = "https://dev.danilafe.com/Nix-Configs/server-config/src/commit/98cffe09546aee1678f7baebdea5eb5fef288935"
path = "server-config"

7
data/submodules.json Normal file
View File

@ -0,0 +1,7 @@
{
"agda-spa": "https://dev.danilafe.com/DanilaFe/agda-spa/src/commit/f0da9a902005b24db4e03a89c2862493735467c4",
"aoc-2020": "https://dev.danilafe.com/Advent-of-Code/AdventOfCode-2020/src/commit/7a8503c3fe1aa7e624e4d8672aa9b56d24b4ba82",
"blog-static-flake": "https://dev.danilafe.com/Nix-Configs/blog-static-flake/src/commit/67b47d9c298e7476c2ca211aac5c5fd961637b7b",
"compiler": "https://dev.danilafe.com/DanilaFe/bloglang/src/commit/137455b0f4365ba3fd11c45ce49781cdbe829ec3",
"server-config": "https://dev.danilafe.com/Nix-Configs/server-config/src/commit/98cffe09546aee1678f7baebdea5eb5fef288935"
}

View File

@ -1,12 +1,10 @@
puts "[params]" require "json"
puts " [params.submoduleLinks]"
def each_submodule(base_path) def each_submodule(base_path)
`cd #{base_path} && git submodule status`.lines do |line| `cd #{base_path} && git submodule status`.lines do |line|
hash, path = line[1..].split " " hash, path = line[1..].split " "
full_path = "#{base_path}/#{path}" full_path = "#{base_path}/#{path}"
url = `git config --file #{base_path}/.gitmodules --get 'submodule.#{path}.url'`.chomp.delete_suffix(".git") url = `git config --file #{base_path}/.gitmodules --get 'submodule.#{path}.url'`.chomp.delete_suffix(".git")
safe_name = full_path.gsub(/\/|-|_\./, "")
if url =~ /dev.danilafe.com/ if url =~ /dev.danilafe.com/
file_url = "#{url}/src/commit/#{hash}" file_url = "#{url}/src/commit/#{hash}"
@ -14,14 +12,15 @@ def each_submodule(base_path)
raise "Submodule URL #{url.dump} not in a known format!" raise "Submodule URL #{url.dump} not in a known format!"
end end
yield ({ :path => full_path, :url => file_url, :name => safe_name }) yield ({ :path => full_path, :url => file_url })
each_submodule(full_path) { |m| yield m } each_submodule(full_path) { |m| yield m }
end end
end end
hash = {}
each_submodule(".") do |m| each_submodule(".") do |m|
next unless m[:path].start_with? "./code/" next unless m[:path].start_with? "./code/"
puts " [params.submoduleLinks.#{m[:name].delete_prefix(".code")}]" hash[m[:path].delete_prefix("./code/")] = m[:url]
puts " url = #{m[:url].dump}"
puts " path = #{m[:path].delete_prefix("./code/").dump}"
end end
puts JSON.pretty_generate(hash)

@ -1 +1 @@
Subproject commit e2fb9362f611bcf7d92ad2f3ae99c904e3fa4474 Subproject commit 77b8d5e65b0162bb448265bd5039054f9a87631a