From 159f466773b90425f1d8cf0c7d7a7e57313f5d45 Mon Sep 17 00:00:00 2001 From: pika Date: Thu, 3 Jul 2025 15:46:16 +0200 Subject: [PATCH] wip --- .zsh/.aliases.zsh | 82 ++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/.zsh/.aliases.zsh b/.zsh/.aliases.zsh index f385de7..ca155ba 100644 --- a/.zsh/.aliases.zsh +++ b/.zsh/.aliases.zsh @@ -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 ' 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 ' 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