File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed
Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,23 @@ MAX_DIFF_CHARS=2000 # Truncate diff to prevent long processing
66TIMEOUT_SECONDS=10 # Max time to wait for LLM response
77MAX_COMMIT_LENGTH=50 # Max characters for commit message
88
9+ # Spinner animation function
10+ spinner () {
11+ local pid=$1
12+ local delay=0.1
13+ local spinstr=' ⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
14+ while ps -p $pid > /dev/null 2>&1 ; do
15+ for (( i= 0 ; i< ${# spinstr} ; i++ )) ; do
16+ printf " \r${spinstr: $i : 1} Generating commit message..."
17+ sleep $delay
18+ if ! ps -p $pid > /dev/null 2>&1 ; then
19+ break
20+ fi
21+ done
22+ done
23+ printf " \r✓ Done! \n"
24+ }
25+
926# Stage all changes
1027git add -A
1128
5067 PROMPT=" Git commit message (max 50 chars, no quotes/formatting):
5168$( echo " $diff " | head -50) "
5269
53- # Run model with timeout
54- commit_message=$( echo " $PROMPT " | timeout $TIMEOUT_SECONDS ollama run " $MODEL " --verbose 2> /dev/null | head -1)
70+ # Run model with timeout and spinner
71+ echo " $PROMPT " | timeout $TIMEOUT_SECONDS ollama run " $MODEL " --verbose 2> /dev/null | head -1 > /tmp/commit_msg.txt &
72+ LLM_PID=$!
73+ spinner $LLM_PID
74+ wait $LLM_PID
75+ exit_code=$?
76+ commit_message=$( cat /tmp/commit_msg.txt)
77+ rm -f /tmp/commit_msg.txt
5578
5679 # Check if timeout occurred or empty response
57- if [ $? -eq 124 ] || [ -z " $commit_message " ]; then
80+ if [ $exit_code -eq 124 ] || [ -z " $commit_message " ]; then
5881 echo " LLM timeout or empty response. Using fallback message."
5982 commit_message=" $fallback_message "
6083 fi
You can’t perform that action at this time.
0 commit comments