1#!/usr/bin/env bash 2# 3# Explicitly switches the relative submodules locations on GitHub to the original public URLs 4# 5# '../../group/repo.git' to 'https://github.com/group/repo.git' 6# 7# This can be useful for non-GitHub forks to automate getting of right submodules sources. 8# 9 10# 11# It makes sense to do 12# 13# git submodule deinit --force . 14# git submodule init 15# 16# before running this, and 17# 18# git submodule update --recursive 19# 20# after that. These were not included over this script deliberately, to use the script flexibly 21# 22 23set -o errexit 24set -o pipefail 25set -o nounset 26 27DEBUG_SHELL=${DEBUG_SHELL:-"0"} 28[ "${DEBUG_SHELL}" = "1" ] && set -x 29 30### '../../' relative locations 31 32for LINE in $(git config -f .gitmodules --list | grep "\.url=../../[^.]") 33do 34 SUBPATH=$(echo "${LINE}" | sed "s|^submodule\.\([^.]*\)\.url.*$|\1|") 35 LOCATION=$(echo "${LINE}" | sed 's|.*\.url=\.\./\.\./\(.*\)$|\1|') 36 SUBURL="https://github.com/$LOCATION" 37 38 git config submodule."${SUBPATH}".url "${SUBURL}" 39done 40 41git config --get-regexp '^submodule\..*\.url$' 42