changed echo coloring for git functions
This commit is contained in:
parent
230877740a
commit
5530994c56
2 changed files with 14 additions and 15 deletions
2
.zshenv
2
.zshenv
|
@ -124,7 +124,7 @@ proxy() {
|
|||
|
||||
# ────────────< check network availability and set proxy if in correct network >────────────
|
||||
noproxy
|
||||
if ping -w2 -q swu.dom; then
|
||||
if ping -c 1 -W 2 swu.dom &>/dev/null; then
|
||||
proxy --set
|
||||
else
|
||||
noproxy
|
||||
|
|
27
.zshrc
27
.zshrc
|
@ -351,50 +351,49 @@ __alias__() {
|
|||
alias ga="gd $1 && git add"
|
||||
alias gp="git submodule update --init --recursive && git pull --recurse-submodule"
|
||||
alias gms='git maintenance start'
|
||||
# alias gsu="git submodule foreach git pull && git submodule update --init --recursive && git add . && git commit -m ' update: submodules' && echo '-- Committed changes, pushing now..' && sleep 1 && git push"
|
||||
alias gcm="git commit -m"
|
||||
alias gpu="git push --recurse-submodule=on-demand"
|
||||
gsu() {
|
||||
echo "${YELLOW}| git submodule update --init --recursive |${NC}"
|
||||
echo "${YELLOW}${BOLD}| git submodule update --init --recursive |${NC}"
|
||||
git submodule update --init --recursive &&
|
||||
echo "${CYAN}-- updated submodules recursively${NC}"
|
||||
echo "${CYAN}${BOLD}-- updated submodules recursively${NC}"
|
||||
|
||||
echo "${YELLOW}-- Checking submodule branches... --${NC}"
|
||||
echo "${YELLOW}${BOLD}-- Checking submodule branches... --${NC}"
|
||||
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 "${RED}Submodule $name is detached. Checking out ${YELLOW} $default_branch${RED}...${NC}"
|
||||
echo "${RED}${BOLD}Submodule $name is detached. Checking out ${YELLOW} $default_branch${RED}...${NC}"
|
||||
git checkout $default_branch
|
||||
else
|
||||
echo "${GREEN}Submodule $name is on branch $branch.${NC}"
|
||||
echo "${GREEN}${BOLD}Submodule $name is on branch $branch.${NC}"
|
||||
fi
|
||||
'
|
||||
|
||||
echo "${YELLOW}git submodule foreach git pull --recurse-submodule${NC}"
|
||||
echo "${YELLOW}${BOLD}git submodule foreach git pull --recurse-submodule${NC}"
|
||||
git submodule foreach git pull --recurse-submodule &&
|
||||
echo "${GREEN}-- pulled down submodules recursively --${NC}"
|
||||
echo "${GREEN}${BOLD}-- pulled down submodules recursively --${NC}"
|
||||
|
||||
gUpdateModules() {
|
||||
if ! git diff --exit-code .; then
|
||||
echo "${CYAN}Staging changes...${NC}"
|
||||
echo "${CYAN}${BOLD}Staging changes...${NC}"
|
||||
git add . || echo "GIT ADD MISSFUNCTION"
|
||||
sleep 0.3
|
||||
if git commit -m " update: submodules"; then
|
||||
echo "${GREEN}Changes committed successfully.${NC}"
|
||||
echo "${GREEN}${BOLD}Changes committed successfully.${NC}"
|
||||
else
|
||||
echo "${RED}${BOLD}Failed to commit changes.${NC}"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo "${GREEN}No changes to commit.${NC}"
|
||||
echo "${GREEN}${BOLD}No changes to commit.${NC}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
if gUpdateModules; then
|
||||
if git push; then
|
||||
echo "${GREEN}Push successful.${NC}"
|
||||
echo "${GREEN}${BOLD}Push successful.${NC}"
|
||||
else
|
||||
echo "${RED}${BOLD}Failed to push changes.${NC}"
|
||||
return 1
|
||||
|
@ -413,12 +412,12 @@ __alias__() {
|
|||
# Check if there are any changes on the remote branch
|
||||
if git diff --quiet "$branch" "origin/$branch"; then
|
||||
local commit_message="${1:-wip}"
|
||||
echo "No changes on the remote branch. Adding changes and pushing with '$commit_message' commit."
|
||||
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
|
||||
git add .
|
||||
git commit -m "$commit_message"
|
||||
git push
|
||||
else
|
||||
echo "There are changes on the remote branch. Please pull the latest changes first."
|
||||
echo "${RED}${BOLD}There are changes on the remote branch. Please pull the latest changes first.${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue