Skip to content

Instantly share code, notes, and snippets.

@ericzakariasson
Created October 14, 2024 07:40
Show Gist options
  • Save ericzakariasson/c4f06bb9c54dad2845695da56abc2da2 to your computer and use it in GitHub Desktop.
Save ericzakariasson/c4f06bb9c54dad2845695da56abc2da2 to your computer and use it in GitHub Desktop.
Small script to answer the question "What did you get done this week?"
#!/bin/bash
START_DATE=$(date -v -$(($(date '+%u') + 6))d '+%Y-%m-%d')
END_DATE=$(date -v -$(date '+%u')d '+%Y-%m-%d')
GIT_LOG=$(git log --since="$START_DATE" --until="$END_DATE" --pretty=format:"%h %s" --no-merges)
[ -z "$GIT_LOG" ] && { echo "No commits found."; exit 1; }
PROMPT="In less than 200 characters, summarize the following git commit history to answer the question 'What did you get done this week?'. Answer in the style of Elon Musk. The reader is in a hurry, so make sure it's easy to digest quickly. Start with 'This week'. ':\n$GIT_LOG"
curl -s https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d "$(jq -n --arg prompt "$PROMPT" \
'{
"model": "gpt-4",
"messages": [{"role": "user", "content": $prompt}],
"max_tokens": 256
}')" | jq -r '.choices[0].message.content'
@ralyodio
Copy link

haha. nice

@Johannes-01
Copy link

Use the --before tag instead of the --until tag.

@ralyodio
Copy link

why what does that do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment