Refactor aicommit_groq script: extract system message to a heredoc, remove redundant variable assignment, and improve code organization

This commit is contained in:
ilguappo 2024-08-07 04:12:18 -07:00
parent cf655b7202
commit 624861e320

View File

@ -5,6 +5,17 @@ set -e
ARGS=("${@-}") ARGS=("${@-}")
TMP_FILE="/tmp/aicommit" TMP_FILE="/tmp/aicommit"
system=$(
cat - <<EOF
You are an expert programmer that values clear, unambiguous communication and are specialized in generating concise and informative git commit messages.
Only reply with the commit message and nothing else.
Give detail for every change in the diff.
EOF
)
pushd "$(pwd)" >/dev/null || exit 1 pushd "$(pwd)" >/dev/null || exit 1
spin() { spin() {
@ -24,7 +35,6 @@ if [[ -z ${GROQ_API_KEY} ]]; then
exit 1 exit 1
fi fi
system="You are an expert programmer that values clear, unambiguous communication and are specialized in generating concise and informative git commit messages. Only reply with the commit message and nothing else."
if ! diff=$(git diff --cached); then if ! diff=$(git diff --cached); then
echo "Failed to get diff." echo "Failed to get diff."