I am attempting to write a script that initializes my git hooks differently whether my git repo is a submodule or just a regular repository. It currently looks like this:
# Get to root directory of client repository
if [[ ":$PATH:" != *":.git/modules:"* ]]; then # Presumed not being used as a submodule
cd ../../
else
cd .. # cd into .git/modules/<nameOfSubmodule> (up one level from hooks)
submoduleName=${PWD##*/} # Get submodule name from current directory
cd ../../../$submoduleName
fi
However in testing it seems to always take the else route even when I am in a submodule.
Is there something I am missing in this line for determining whether my path contains the expected characters?
if [[ ":$PATH:" != ":.git/modules:" ]]