-
-
Save Tirael/ddce04648cee14e1d505664b328054b6 to your computer and use it in GitHub Desktop.
replace external submodules in gitlab pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include: | |
- project: 'devops/ci' | |
ref: master | |
file: '/gitlab/scripts.yml' | |
before_script: | |
- !reference [.scripts, replace_external_submodules] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
replace_external_submodules: | | |
exists_in_list () { | |
list=$1 | |
delimiter=$2 | |
value=$3 | |
list_whitespaces=`echo $list | tr "$delimiter" " "` | |
for x in $list_whitespaces; do | |
if [ "$x" = "$value" ]; then | |
return 0 | |
fi | |
done | |
return 1 | |
} | |
if [ ! -f ".gitmodules" ]; then | |
echo "INFO: .gitmodules not exist"; | |
else | |
echo "INFO: .gitmodules exist"; | |
external_submodules="benchmark.git,abseil.git,googletest.git,tlx.git,trompeloeil.git" | |
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | | |
while read path_key path | |
do | |
url_key=$(echo $path_key | sed 's/\.path/.url/') | |
url=$(git config -f .gitmodules --get "$url_key") | |
repo="${url##*/}" | |
repo=${repo%.*}.git | |
echo $repo | |
if exists_in_list "$external_submodules" "," $repo ; then | |
repo="../external_submodules/${repo}" | |
echo "Add submodule ${repo}" | |
git submodule add $repo $path | |
fi | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment