This commit is contained in:
pika 2025-07-03 15:46:16 +02:00
parent 382312eb23
commit 159f466773

View file

@ -495,61 +495,47 @@ __git__() {
local commit_files=()
local commit_message
case "$1" in
'.')
commit_files=.
commit_message="wip"
# case "$1" in
# '.')
# commit_files=.
# commit_message="wip"
#
# echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
#
# git add "$commit_files"
# git commit -m "$commit_message"
# git push
# ;;
# *)
if [[ -n "$1" ]]; then
for f in "$@"; do
if [ -f "./$f" ] || [ -d "./${f}" ]; then
commit_files+=("${f}")
else
commit_message+="${f}"
break
fi
done
else
echo "${BOLD}${YELLOW}You have to provide the command like..:"
echo "${GREEN}'gwip <list of files> <commit message>' or like 'gwip .'${NC}"
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
# echo "${GREEN}Committed files: ${BOLD}${commit_files[*]}${NC}"
return
fi
git add "$commit_files"
git commit -m "$commit_message"
git push
;;
case $commit_files in
'.') ;;
*)
if [[ -n "$1" ]]; then
for f in "$@"; do
if [ -e "$f" ]; then
commit_files+=("$f")
# shift
else
commit_message+="${f}"
break
fi
done
else
echo "${BOLD}${YELLOW}You have to provide the command like..:"
echo "${GREEN}'gwip <list of files> <commit message>' or like 'gwip .'${NC}"
return
fi
[[ -z "$commit_files" ]] && commit_files=.
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
echo "${GREEN}Committed files: ${BOLD}${commit_files[*]}${NC}"
# for f in "${commit_files[@]}"; do
# echo git add "$f"
# done
git add "${commit_files[*]}"
git commit -m "${commit_message:-wip}"
git push
;;
esac
# if [ -n "$2" ]; then
# commit_files="$1"
# commit_message="$2"
# else
# if [ -e "$1" ]; then
# commit_files="$1"
# commit_message="wip"
# else
# commit_files="."
# commit_message="${1:-wip}"
# fi
# fi
[[ -z "$commit_files" ]] && commit_files=.
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
git add "${commit_files[*]}"
git commit -m "${commit_message:-wip}"
git push
else
echo "${RED}${BOLD}There are changes on the remote branch. Please pull the latest changes first.${NC}"
fi