feat(git): enhance git folder scripts with validation and error handling for missing submodules and existing directories
This commit is contained in:
4 files changed
+31
-8
No files matched your search
@@ -13,10 +13,16 @@ switch-git-folder() {
|
||||
local git_branch="$1"
|
||||
local git_folders=$(ls-git-folder "$2")
|
||||
for git_folder in $git_folders; do
|
||||
|
||||
git_folder="${git_folder#./}"
|
||||
|
||||
local shallow=$(git config --file .gitmodules --get submodule."$git_folder".shallow)
|
||||
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
|
||||
|
||||
if [[ "$shallow" = "true" ]]; then
|
||||
echo "Fetch branch $git_branch (shallow) from origin and then switch."
|
||||
|
||||
Reference in new issue
Block a user