]> git.nbdom.net Git - nb.git/commitdiff
gitf_commit
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 14 Nov 2023 18:33:03 +0000 (19:33 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 14 Nov 2023 18:33:03 +0000 (19:33 +0100)
etc/profile.d/git.sh

index 8cbe52069dc51acf536929aa928db4ba656a5023..19a868ceb80890bc5430439322dbc1d8bd495f4b 100644 (file)
@@ -50,6 +50,19 @@ EOF
        cd "$pwd"
 }
 
+gitf_commit() {
+       declare file="${1:?Args 1: file is missing}"
+       declare default="${file##$(git_root)/}"
+       declare comment
+       read -e -p "Your comment: " -i "$default" comment
+       if [ -z "$comment" ]
+       then
+         echo "> Commit canceled because of empty comment!"
+               return 1
+       fi
+       git commit -m "$comment" -a
+}
+
 gitf_publish() {
        case "$@" in
                --help|-h)
@@ -74,19 +87,10 @@ EOF
        #
        # Commit
        #
-       declare comment
        if [ -n "$(git status --porcelain "$file")" ]
        then
                printf "$fmt" "COMMIT"
-               declare default="${file##$(git_root)/}"
-               read -e -p "Your comment: " -i "$default" comment
-               if [ -z "$comment" ]
-               then
-               echo "> Commit canceled because of empty comment!"
-                       return 1
-               fi
-               # NB 12.05.23 git commit -m "$comment" "$file"
-               git commit -m "$comment" -a
+               gitf_commit "$file"
        fi
 
 
@@ -144,46 +148,6 @@ git_cache_rm() {
        echo git filter-branch --index-filter "git rm --cached --ignore-unmatch $@" --force --prune-empty -- --all
 }
 
-# NB 03.05.23 gitcd() {
-# NB 03.05.23 
-       # NB 03.05.23 shell_help_noarg "Change directory to run git commands\nUsage: $FUNCNAME FILE|DIR GIT_ARGUMENTS" "$@" && return 1
-       # NB 03.05.23 local i d dir args
-       # NB 03.05.23 local pwd; pwd=$PWD
-       # NB 03.05.23 #for i in $@; do
-# NB 03.05.23 
-       # NB 03.05.23 while [ $# -gt 0 ]; do
-# NB 03.05.23 
-               # NB 03.05.23 i="$1"
-# NB 03.05.23 
-               # NB 03.05.23 # Replace file with realpath
-               # NB 03.05.23 if [ -e "$i" ]; then
-                       # NB 03.05.23 i=$(realpath "$i")
-# NB 03.05.23 
-                       # NB 03.05.23 # if dir stay there
-                       # NB 03.05.23 #[ -d "$i" ] && i="$i/.git"
-                       # NB 03.05.23 [ -d "$i" ] && i="$i/README.md"
-# NB 03.05.23 
-                       # NB 03.05.23 d=$(dirname "$i")
-# NB 03.05.23 
-                       # NB 03.05.23 dir="$d"
-               # NB 03.05.23 fi
-# NB 03.05.23 
-               # NB 03.05.23 shell_push_arg "$i" args
-               # NB 03.05.23 shift
-# NB 03.05.23 
-       # NB 03.05.23 done
-# NB 03.05.23 
-       # NB 03.05.23 [ -z "$dir" ] && echo "Can't find any file in $@" && return 1
-# NB 03.05.23 
-       # NB 03.05.23 cd "$dir" || return
-       # NB 03.05.23 #echo PWD=$(pwd)
-# NB 03.05.23 
-       # NB 03.05.23 eval git ${args}
-# NB 03.05.23 
-       # NB 03.05.23 cd "$pwd"
-# NB 03.05.23 
-# NB 03.05.23 } # < gitcd()
-
 git_commit_push() {
        git commit -a -m "$*" && git push
 }