From 81858b179b577e22501e3087f86dff807ed1ab00 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 1 Dec 2025 16:17:05 +0100 Subject: [PATCH 1/2] Add script to gather git submodules Running this on a recursively cloned git repository will show all submodules, its path and commit hash formatted as a Python dict which can be used in easyconfigs. --- easybuild/scripts/get-submodule-info.sh | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 easybuild/scripts/get-submodule-info.sh diff --git a/easybuild/scripts/get-submodule-info.sh b/easybuild/scripts/get-submodule-info.sh new file mode 100755 index 0000000000..baa545e8df --- /dev/null +++ b/easybuild/scripts/get-submodule-info.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +echo "Print information on all submodules for the git repository in $PWD" +echo +echo "Format: '': ('/', '', '')," +echo + +function print_submodules { + local base_path=$1 + git -C "$base_path" submodule status | while read -r line; do + # Example line: " 3a6b7dc libs/foo (heads/main)" + commit=$(echo "$line" | awk '{print $1}') + path=$(echo "$line" | awk '{print $2}') + + if [[ -z $base_path ]]; then + sub_folder=$path + else + sub_folder=$base_path/$path + fi + + # Extract owner/repo from URL + url=$(git config --file "${base_path:-$PWD}/.gitmodules" --get "submodule.$path.url") + repo_slug=$(echo "$url" | sed -E 's#.*[:/]([^/:]+/[^/.]+)(\.git)?$#\1#') + + name=$(basename "$path") + short_commit=$(git -C "$sub_folder" rev-parse --short "$commit" 2>/dev/null || echo "$commit") + + printf "'%s': ('%s', '%s', '%s'),\n" "$name" "$repo_slug" "$short_commit" "$sub_folder" + print_submodules "$sub_folder" + done +} + +print_submodules "" | sort From a39c5429e72c6f9bcbacb12b958945fa87685deb Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 3 Dec 2025 09:48:19 +0100 Subject: [PATCH 2/2] Add license and author --- easybuild/scripts/get-submodule-info.sh | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/easybuild/scripts/get-submodule-info.sh b/easybuild/scripts/get-submodule-info.sh index baa545e8df..f7a823e3c6 100755 --- a/easybuild/scripts/get-submodule-info.sh +++ b/easybuild/scripts/get-submodule-info.sh @@ -1,4 +1,37 @@ #!/bin/bash +## +# Copyright 2025-2025 Ghent University +# +# This file is part of EasyBuild, +# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), +# with support of Ghent University (http://ugent.be/hpc), +# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), +# Flemish Research Foundation (FWO) (http://www.fwo.be/en) +# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). +# +# https://github.com/easybuilders/easybuild +# +# EasyBuild is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation v2. +# +# EasyBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with EasyBuild. If not, see . +## +""" +Utility to gather submodules of an existing, recursively cloned repository +in the current working directory. + +The output is a dictionary mapping submodule names to their repository slug, commit hash and relative path. + +author: Alexander Grund (TU Dresden) +""" + echo "Print information on all submodules for the git repository in $PWD" echo