diff --git a/CHANGELOG.md b/CHANGELOG.md index 27a299a..63f69e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,3 +84,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - jq: Argument list too long #3 - Cleaned up temporary files after API call. + +## [1.7.1] - 2024-12-02 + +### Fixed + +- prepare-commit-msg.sh: line 237: /usr/bin/curl: Argument list too long diff --git a/prepare-commit-msg.sh b/prepare-commit-msg.sh index 7702a0c..3a7d1e5 100755 --- a/prepare-commit-msg.sh +++ b/prepare-commit-msg.sh @@ -228,16 +228,22 @@ REQUEST_BODY=$(jq -n \ }' ) debug_log "Request body prepared with model: $MODEL" "$REQUEST_BODY" +debug_log "Cleaning up temporary files" +rm -v "$PROMPT_FILE" "$SYSTEM_PROMPT_FILE" + +REQUEST_BODY_FILE=$(mktemp) +echo "$REQUEST_BODY" > "$REQUEST_BODY_FILE" +debug_log "Request body saved to $REQUEST_BODY_FILE" # Make the API request debug_log "Making API request to OpenRouter" RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \ -H "Authorization: Bearer ${OPENROUTER_API_KEY}" \ -H "Content-Type: application/json" \ - -d "$REQUEST_BODY") + -d @"$REQUEST_BODY_FILE") debug_log "API response received" "$RESPONSE" debug_log "Cleaning up temporary files" -rm -v "$PROMPT_FILE" "$SYSTEM_PROMPT_FILE" +rm -v "$REQUEST_BODY_FILE" # Check for errors if [[ "$RESPONSE" == *'"error"'* ]]; then