fix gsu
This commit is contained in:
parent
4961cf01b0
commit
78d44ea65a
1 changed files with 19 additions and 15 deletions
34
.zshrc
34
.zshrc
|
@ -354,23 +354,26 @@ __alias__() {
|
||||||
alias gcm="git commit -m"
|
alias gcm="git commit -m"
|
||||||
alias gpu="git push --recurse-submodule=on-demand"
|
alias gpu="git push --recurse-submodule=on-demand"
|
||||||
gsu() {
|
gsu() {
|
||||||
echo_info "Pulling submodules..."
|
echo "| git submodule foreach git pull --recurse-submodule |"
|
||||||
if git submodule foreach git pull --recurse-submodule; then
|
git submodule foreach git pull --recurse-submodule &&
|
||||||
echo_info "Submodules pulled successfully."
|
echo "-- pulled down submodules recursively"
|
||||||
else
|
|
||||||
echo_error "Failed to pull submodules."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo_info "Updating submodules..."
|
echo "| git submodule update --init --recursive |"
|
||||||
if git submodule update --init --recursive; then
|
git submodule update --init --recursive
|
||||||
echo_info "Submodules updated successfully."
|
|
||||||
else
|
|
||||||
echo_error "Failed to update submodules."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
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..."
|
echo_info "Staging changes..."
|
||||||
git add .
|
git add .
|
||||||
sleep 0.3
|
sleep 0.3
|
||||||
|
@ -391,6 +394,7 @@ __alias__() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
gwip() {
|
gwip() {
|
||||||
# Fetch the latest changes from the remote
|
# Fetch the latest changes from the remote
|
||||||
git fetch
|
git fetch
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue