From: Nicolas Boisselier Date: Tue, 14 Nov 2023 18:33:03 +0000 (+0100) Subject: gitf_commit X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=068d3c51587b75c9eed96c430b6204996e5303e7;p=nb.git gitf_commit --- diff --git a/etc/profile.d/git.sh b/etc/profile.d/git.sh index 8cbe5206..19a868ce 100644 --- a/etc/profile.d/git.sh +++ b/etc/profile.d/git.sh @@ -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 }