@@ -6,6 +6,8 @@ source "${_SCRIPT_DIR}/.command_defaults.sh" || exit 1
66set -o errexit -o errtrace -o nounset
77# #################################################################################################################################################
88
9+ declare -x commit_message commit_files=() args_are_files=" ${args_are_files:- false} "
10+
911# ################################################################## USAGE ########################################################################
1012_SCRIPT_NAME=" $( basename " $0 " ) "
1113
1820 ${_SCRIPT_NAME}
1921
2022SYNOPSIS
21- ${_SCRIPT_NAME} [--cd-to-git-base-dir] [--files] [--select-files] [--file | -f <file_to_commit>...] [--message | -m <message>] <message_or_files>
23+ ${_SCRIPT_NAME} [--cd-to-git-base-dir] [--files] [--select-files] [--file | -f <file_to_commit>...] [--message | -m <message>] [--use-files-for-message-if-missing] <message_or_files>
2224 ${SYNOP_INDENT} [--help] [--debug] [--verbose]
2325
2426EXAMPLES
2729}
2830# #################################################################################################################################################
2931
30- args_are_files=" ${args_are_files:- false} "
31- commit_files=()
32-
3332# ################################################################ SCRIPTARGS #####################################################################
3433while test $# -gt 0; do
3534 case " $1 " in
@@ -68,6 +67,10 @@ while test $# -gt 0; do
6867 args_are_files=true
6968 shift
7069 ;;
70+ --use-files-for-message-if-missing)
71+ use_files_for_message_if_missing=true
72+ shift
73+ ;;
7174 --)
7275 shift
7376 args_are_files=true
@@ -85,6 +88,10 @@ while test $# -gt 0; do
8588done
8689# #################################################################################################################################################
8790
91+ function ask_for_commit_message() {
92+ commit_message=" $( ask_user_for_input " Please enter a commit message" ) "
93+ }
94+
8895function main() {
8996 if check_true " ${cd_to_git_base_dir-} " ; then
9097 cd " $( git base-dir) "
@@ -99,16 +106,25 @@ function main() {
99106 mapfile -t -O " ${# commit_files[@]} " commit_files < <( git ls-files --others --exclude-standard --modified | fzf --ansi --multi --no-sort --layout " reverse" --header " Select files to commit" )
100107 fi
101108
102- if test " ${# commit_files[@]} " -eq 0; then
103- commit_files+=(--all)
104- fi
105-
106109 if test -n " ${1-} " ; then
107110 commit_message=" ${commit_message-} $* "
108111 fi
109112
110113 if test -z " ${commit_message-} " ; then
111- commit_message=" $( ask_user_for_input " Please enter a commit message" ) "
114+ if test " ${use_files_for_message_if_missing-} " = " true" ; then
115+ if test " ${# commit_files[@]} " -eq 0; then
116+ echo " No files for commit message"
117+ ask_for_commit_message
118+ else
119+ commit_message=" Update files: $( join_by ' ' " ${commit_files[@]} " ) "
120+ fi
121+ else
122+ ask_for_commit_message
123+ fi
124+ fi
125+
126+ if test " ${# commit_files[@]} " -eq 0; then
127+ commit_files+=(--all)
112128 fi
113129
114130 if check_debug; then
0 commit comments