From 78d44ea65a0c7b6118385d051e316fda54bc0496 Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 24 Mar 2025 14:21:47 +0100 Subject: [PATCH] fix gsu --- .zshrc | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/.zshrc b/.zshrc index 43e6805..90695fe 100644 --- a/.zshrc +++ b/.zshrc @@ -354,23 +354,26 @@ __alias__() { alias gcm="git commit -m" alias gpu="git push --recurse-submodule=on-demand" gsu() { - echo_info "Pulling submodules..." - if git submodule foreach git pull --recurse-submodule; then - echo_info "Submodules pulled successfully." - else - echo_error "Failed to pull submodules." - return 1 - fi + echo "| git submodule foreach git pull --recurse-submodule |" + git submodule foreach git pull --recurse-submodule && + echo "-- pulled down submodules recursively" - echo_info "Updating submodules..." - if git submodule update --init --recursive; then - echo_info "Submodules updated successfully." - else - echo_error "Failed to update submodules." - return 1 - fi + echo "| git submodule update --init --recursive |" + git submodule update --init --recursive - if git diff .; then + echo "-- Checking submodule branches... --" + git submodule foreach ' + branch=$(git symbolic-ref --short HEAD 2>/dev/null || echo "detached") + if [ "$branch" = "detached" ]; then + default_branch=$(git config -f $toplevel/.gitmodules submodule.$name.branch || echo "main") + echo "Submodule $name is detached. Checking out $default_branch..." + git checkout $default_branch + else + echo "Submodule $name is on branch $branch." + fi + ' + + if git diff --quiet .; then echo_info "Staging changes..." git add . sleep 0.3 @@ -391,6 +394,7 @@ __alias__() { return 1 fi } + gwip() { # Fetch the latest changes from the remote git fetch