Skip to content

Commit 0e63a52

Browse files
committed
[git_commit_and_push_all] various updates
1 parent 45e2fcd commit 0e63a52

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

dotfiles/bin/.common_copy.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ function log_and_run_if_not_debug() {
245245
log_with_title_sep_no_leading_blank_line "$(get_args_quoted "$@")" >&2
246246
"$@"
247247
}
248+
function log_and_run_spaced_surround_if_not_debug() {
249+
if check_debug; then
250+
get_args_quoted "$@" >&2
251+
return 0
252+
fi
253+
log_and_run_spaced_surround "$@"
254+
}
248255
function log_stderr() {
249256
echo "$@" >&2
250257
}

dotfiles/bin/git-lazy

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ source "${_SCRIPT_DIR}/.command_defaults.sh" || exit 1
66
set -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

@@ -18,7 +20,7 @@ NAME
1820
${_SCRIPT_NAME}
1921
2022
SYNOPSIS
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
2426
EXAMPLES
@@ -27,9 +29,6 @@ EOF
2729
}
2830
##################################################################################################################################################
2931

30-
args_are_files="${args_are_files:-false}"
31-
commit_files=()
32-
3332
################################################################# SCRIPTARGS #####################################################################
3433
while 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
8588
done
8689
##################################################################################################################################################
8790

91+
function ask_for_commit_message() {
92+
commit_message="$(ask_user_for_input "Please enter a commit message")"
93+
}
94+
8895
function 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

Comments
 (0)