style: formatting

This commit is contained in:
Rejman Nascimento 2024-03-01 08:25:07 -03:00
commit 25a980ef46

View file

@ -24,21 +24,23 @@ _git_commit_flags=(
) )
remove_flags() { remove_flags() {
local regex=$(IFS="|"; echo "${_git_commit_flags[*]}") local regex=$(
IFS="|"
echo "${_git_commit_flags[*]}"
)
echo $(sed -E "s/\s($regex)\s|\s($regex)$//g" <<< "$1") echo $(sed -E "s/\s($regex)\s|\s($regex)$//g" <<<"$1")
}; }
build_message () { build_message() {
local argv=("$@") local argv=("$@")
local argc=${#@} local argc=${#@}
local i=1 local i=1
while [[ $i -lt $argc ]]; while [[ $i -lt $argc ]]; do
do
local flag="${argv[$i]}" local flag="${argv[$i]}"
local value="${argv[$i + 1]}" local value="${argv[$i + 1]}"
local next=$[$i + 1] local next=$(($i + 1))
if [[ "$flag" =~ (-sa|-as) ]]; then if [[ "$flag" =~ (-sa|-as) ]]; then
local attention='!' local attention='!'
@ -55,14 +57,14 @@ build_message () {
local scope="($value)" local scope="($value)"
i=$next i=$next
fi fi
i=$next i=$next
done done
local template="'$type'${scope}$attention: ${@}"; local template="'$type'${scope}$attention: ${@}"
local message=$(remove_flags "$template" "${_git_commit_flags[@]}") local message=$(remove_flags "$template" "${_git_commit_flags[@]}")
git commit -m "$message" git commit -m "$message"
}; }
local alias type local alias type
for type in "${_git_commit_aliases[@]}"; do for type in "${_git_commit_aliases[@]}"; do