Skip to content

Instantly share code, notes, and snippets.

@julioflima
Created February 10, 2025 10:16
Show Gist options
  • Save julioflima/4040e4fe55ee051dceb972b27a7eea26 to your computer and use it in GitHub Desktop.
Save julioflima/4040e4fe55ee051dceb972b27a7eea26 to your computer and use it in GitHub Desktop.
Daily
#!/bin/bash
# Do it:
# git config --global alias.daily '!~/projects/scripts/daily.sh'
# git daily
# Define variables
AUTHOR_NAME="Julio Lima"
TODAY=$(date "+%Y-%m-%d")
API_KEY="your-openai-api-key" # Replace with your OpenAI API key
MODEL="gpt-4" # Change to "gpt-3.5-turbo" if needed
echo "Fetching commits for today ($TODAY)..."
# Get commit logs
COMMITS=$(git --no-pager log --author="$AUTHOR_NAME" --since="$TODAY 00:00" --until="$TODAY 23:59" --pretty=format:"- %h %s")
if [[ -z "$COMMITS" ]]; then
echo "No commits found for today."
exit 1
fi
echo "Sending commits to AI for summarization..."
# Create the OpenAI request payload
JSON_PAYLOAD=$(jq -n \
--arg model "$MODEL" \
--arg prompt "Summarize these Git commits into a concise bullet-point report:\n\n$COMMITS" \
'{model: $model, messages: [{role: "system", content: "You are an AI assistant that summarizes Git commit logs into concise end-of-day reports."}, {role: "user", content: $prompt}], temperature: 0.7}')
# Call OpenAI API
SUMMARY=$(curl -s -X POST "https://api.openai.com/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d "$JSON_PAYLOAD" | jq -r '.choices[0].message.content')
# Output the summary
echo -e "\n📌 **End of Day Summary:**"
echo "----------------------------------"
echo "$SUMMARY"
echo "----------------------------------"
# Optionally, save the summary to a file
echo "$SUMMARY" > "summary_$TODAY.txt"
echo "Summary saved to summary_$TODAY.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment