added primitive protocol switcher for submodules

This commit is contained in:
mrfry 2023-04-11 08:37:01 +02:00
parent 8647088faf
commit 7d1bddd7e2
6 changed files with 75 additions and 10 deletions

22
scripts/switchGitProtocol.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
gitDir=".git"
gitmoduleFile=".gitmodules"
sshGitmodulesFile=".gitmodules.ssh"
httpsGitmodulesFile=".gitmodules.https"
function error() { echo -e "\033[0;41m${1}\033[0m"; exit 1; }
if [ ! -d "${gitDir}" ]; then
error "${gitDir} does not exist! Maybe you ran this script in the wrong directory"
fi
if [ "$1" != "ssh" ] && [ "$1" != "https" ]; then
error "Invalid param! Valid params are: 'ssh', 'https'"
fi
if [ "$1" == "ssh" ]; then
cp -v "$sshGitmodulesFile" "$gitmoduleFile"
elif [ "$1" == "https" ]; then
cp -v "$httpsGitmodulesFile" "$gitmoduleFile"
fi