I am working on a script to update submodules for various projects in a CI environment. The single script needs to take care following three cases:
- Project that always needs master branch of the submodule.
- Project that has reference to specific branch of the submodule.
- Project that has reference to specific commit of the submodule.
Is it possible to create this single script to handle the submodule update from the parent project for all these different cases?
git submodule foreach git pull
would handle case 1 and 2 but not 3.
git submodule foreach git pull origin master
would handle 1 but also 3 in some sense as it won't fail.
Is there anyway to add conditional logic after foreach so I can get all submodules properly updated? Or am I trying to fix the problem in a wrong way? Any help would be appreciated!