chore: Automated Nix config update

This commit is contained in:
Andrei Lazarescu 2025-05-31 00:18:20 +03:00
parent aafbdf2772
commit a3d4252779

View File

@ -131,7 +131,7 @@ Generate ONLY the commit message. Do not include any other explanatory text.
EOF EOF
) )
echo "🧠 Generating commit message with Ollama ($OLLAMA_MODEL)..." echo "🧠 Generating commit message with Ollama ($OLLAMA_MODEL)..." >&2
local json_payload local json_payload
json_payload=$(jq -n \ json_payload=$(jq -n \
--arg model "$OLLAMA_MODEL" \ --arg model "$OLLAMA_MODEL" \
@ -160,7 +160,7 @@ EOF
"$OLLAMA_HOST/api/generate") "$OLLAMA_HOST/api/generate")
if [ -z "$ollama_response" ]; then if [ -z "$ollama_response" ]; then
echo "❌ Ollama request failed or returned empty. Using default commit message." echo "❌ Ollama request failed or returned empty. Using default commit message." >&2
echo "chore: Automated Nix config update $(date +'%Y-%m-%d %H:%M:%S')" echo "chore: Automated Nix config update $(date +'%Y-%m-%d %H:%M:%S')"
return return
fi fi
@ -169,13 +169,13 @@ EOF
generated_message=$(echo "$ollama_response" | jq -r '.response | sub("^\\s*"; "") | sub("\\s*$"; "")') generated_message=$(echo "$ollama_response" | jq -r '.response | sub("^\\s*"; "") | sub("\\s*$"; "")')
if [ -z "$generated_message" ] || [[ "$generated_message" == "null" ]]; then if [ -z "$generated_message" ] || [[ "$generated_message" == "null" ]]; then
echo "⚠️ Ollama did not return a valid message. Using default commit message." echo "⚠️ Ollama did not return a valid message. Using default commit message." >&2
echo "chore: Automated Nix config update $(date +'%Y-%m-%d %H:%M:%S')" echo "chore: Automated Nix config update $(date +'%Y-%m-%d %H:%M:%S')"
else else
if [[ "$generated_message" =~ ^[a-z]+(\([a-zA-Z0-9_-]+\))?!?: ]]; then if [[ "$generated_message" =~ ^[a-z]+(\([a-zA-Z0-9_-]+\))?!?: ]]; then
echo "$generated_message" echo "$generated_message"
else else
echo "⚠️ Ollama message doesn't look like a conventional commit. Prepending 'chore: '." echo "⚠️ Ollama message doesn't look like a conventional commit. Prepending 'chore: '." >&2
echo "chore: $generated_message" echo "chore: $generated_message"
fi fi
fi fi