Files
git.taskfile.build/bin/pull-git-folder
T

29 lines
835 B
Bash
Executable File

#!/bin/bash
pull-git-folder() {
if [[ -z "$1" ]]; then
echo '$1/branch is empty.'
exit
fi
if [[ -z "$2" ]]; then
echo '$2/path is empty.'
exit
fi
local git_folders=$(ls-git-folder "$2")
for git_folder in $git_folders; do
git_folder="${git_folder#./}"
local git_folder_path=$(git config --file .gitmodules --get submodule."$git_folder".path)
local git_folder_url=$(git config --file .gitmodules --get submodule."$git_folder".url)
if [[ -z "$git_folder_path" ]] || [[ -z "$git_folder_url" ]]; then
echo "Skipping: '$git_folder' not defined in .gitmodules."
continue
fi
echo "Pull git folder $git_folder."
git -C "$git_folder" stash
git -C "$git_folder" pull origin "$1"
done
}