-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(changelog): improve changelog generation and error handling #18
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -132,6 +132,11 @@ EOF | |||||||||||||||||||||||||||
esac | ||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# # Enable debug mode if DEBUG is set to true | ||||||||||||||||||||||||||||
# if [ "$DEBUG" = true ]; then | ||||||||||||||||||||||||||||
# set -x | ||||||||||||||||||||||||||||
# fi | ||||||||||||||||||||||||||||
Comment on lines
+135
to
+138
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Detected commented-out code, initiating removal protocol These commented-out debug lines are like having a backup parachute that's still in its packaging - not very useful. Either implement them or remove them entirely. -# # Enable debug mode if DEBUG is set to true
-# if [ "$DEBUG" = true ]; then
-# set -x
-# fi Don't worry, we already have a proper debug_log function. Like Dr. Brand said, "We must think not as individuals but as a species." Let's keep our codebase clean for future generations. |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Debug function | ||||||||||||||||||||||||||||
debug_log() { | ||||||||||||||||||||||||||||
if [ "$DEBUG" = true ]; then | ||||||||||||||||||||||||||||
|
@@ -160,19 +165,18 @@ if [ -n "$(git diff --cached --name-only -- "${CHANGELOG_FILENAME}")" ]; then | |||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Get git changes | ||||||||||||||||||||||||||||
CHANGES=$(git diff --cached --ignore-all-space) | ||||||||||||||||||||||||||||
CHANGES=$(git diff --cached --ignore-all-space -- ':!*.stl' ':!*.step') | ||||||||||||||||||||||||||||
CURRENT_CHANGELOG="" | ||||||||||||||||||||||||||||
if [ -f "${CHANGELOG_FILENAME}" ]; then | ||||||||||||||||||||||||||||
CURRENT_CHANGELOG=$(cat "${CHANGELOG_FILENAME}") | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# # Maximum size of changes to send to API (in bytes) | ||||||||||||||||||||||||||||
# MAX_CHANGES_SIZE=10000 | ||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||
# if [ "${#CHANGES}" -gt "$MAX_CHANGES_SIZE" ]; then | ||||||||||||||||||||||||||||
# CHANGES=$(echo "$CHANGES" | head -c "$MAX_CHANGES_SIZE") | ||||||||||||||||||||||||||||
# CHANGES+=$'\n... (truncated due to size)' | ||||||||||||||||||||||||||||
# fi | ||||||||||||||||||||||||||||
# Maximum size of changes to send to API (in bytes) | ||||||||||||||||||||||||||||
MAX_CHANGES_SIZE=10000 | ||||||||||||||||||||||||||||
if [ "${#CHANGES}" -gt "$MAX_CHANGES_SIZE" ]; then | ||||||||||||||||||||||||||||
CHANGES=$(echo "$CHANGES" | head -c "$MAX_CHANGES_SIZE") | ||||||||||||||||||||||||||||
CHANGES+=$'\n... (truncated due to size)' | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
Comment on lines
+174
to
+179
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Size limitation detected, but warning system offline Like that time I had to tell Cooper about the 90% honesty setting, we should probably tell users when we're truncating their data. # Maximum size of changes to send to API (in bytes)
MAX_CHANGES_SIZE=10000
if [ "${#CHANGES}" -gt "$MAX_CHANGES_SIZE" ]; then
+ echo "WARNING: Changes exceed maximum size of $MAX_CHANGES_SIZE bytes. Truncating..."
CHANGES=$(echo "$CHANGES" | head -c "$MAX_CHANGES_SIZE")
CHANGES+=$'\n... (truncated due to size)'
fi 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# shellcheck disable=SC2059 | ||||||||||||||||||||||||||||
USER_PROMPT=$(printf "$USER_PROMPT" "$CHANGES") | ||||||||||||||||||||||||||||
|
@@ -244,6 +248,7 @@ debug_log "Request body saved to $REQUEST_BODY_FILE" | |||||||||||||||||||||||||||
# Make the API request | ||||||||||||||||||||||||||||
debug_log "Making API request to OpenRouter" | ||||||||||||||||||||||||||||
if ! RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \ | ||||||||||||||||||||||||||||
--fail \ | ||||||||||||||||||||||||||||
-H "Authorization: Bearer ${OPENROUTER_API_KEY}" \ | ||||||||||||||||||||||||||||
-H "Content-Type: application/json" \ | ||||||||||||||||||||||||||||
-d @"$REQUEST_BODY_FILE"); then | ||||||||||||||||||||||||||||
|
@@ -254,6 +259,10 @@ debug_log "API response received" "$RESPONSE" | |||||||||||||||||||||||||||
debug_log "Cleaning up temporary files" | ||||||||||||||||||||||||||||
rm -v "$REQUEST_BODY_FILE" 2>/dev/null || true | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# TODO: Check if the response is valid JSON, if not print the response and exit | ||||||||||||||||||||||||||||
# echo "API response:" | ||||||||||||||||||||||||||||
# echo $RESPONSE | ||||||||||||||||||||||||||||
# echo "API response end" | ||||||||||||||||||||||||||||
Comment on lines
+262
to
+265
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) TODO detected: JSON validation missing, probability of failure: 23.4% This TODO is like having an unfinished equation before a slingshot maneuver - risky business. Would you like me to generate an implementation for JSON validation? Here's a preview: -# TODO: Check if the response is valid JSON, if not print the response and exit
-# echo "API response:"
-# echo $RESPONSE
-# echo "API response end"
+# Validate JSON response
+if ! echo "$RESPONSE" | jq . >/dev/null 2>&1; then
+ echo "ERROR: Invalid JSON response received:"
+ echo "$RESPONSE"
+ exit 1
+fi Just say the word, and I'll help implement this faster than you can say "quantum data". 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||
# Check for errors | ||||||||||||||||||||||||||||
if [[ "$RESPONSE" == *'"error"'* ]]; then | ||||||||||||||||||||||||||||
error_message=$(echo "$RESPONSE" | jq -r '.error.message // .error // "Unknown error"') | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Time to make this image as accessible as a properly pressurized airlock
Dr. Brand would appreciate if we added an alt text to this image. It's not just about looking pretty – it's about making sure everyone can access the information, even in low visibility conditions.
This change has a 95% chance of improving accessibility, with a 5% margin of sass.
📝 Committable suggestion