You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
diff=$(echo $diff| sed 's/\\/\\\\/g'| sed 's/"/\\"/g'| sed 's/\n/\\n/g')
45
+
# diff=$(echo $diff | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed 's/\n/\\n/g')
46
+
47
+
# Default model (change if desired)
48
+
MODEL="gemma3:4b"
49
+
50
+
# Prepare the prompt
51
+
PROMPT=$(printf "You are an expert software engineer and technical writer. Write a clear, professional commit message based on the following Git diff. Requirements:\n- Summarize the purpose and key changes made, like if a file was created, edited, moved or deleted.\n- Include which files were created, modified, deleted (removed), or moved if applicable.\n- Do NOT include quotes, explanations, diff syntax, markdown formatting, or any additional text or formatting.\n- Limit your response to 20 tokens.\n\n Respond in the following format:\nCommit message: <Your concise commit message>\n\nGit diff:\n%s""$diff")
52
+
53
+
# Run the model and capture output
54
+
commit_message=$(echo "$PROMPT"| ollama run "$MODEL")
46
55
47
56
# Prepare the Gemini API request
48
-
gemini_request='{"contents":[{"parts":[{"text": "Write a git commit message title (no more than 72 characters total) for the following git diff: '"$diff"' Do not include any other text in the repsonse."}]}]}'
57
+
#gemini_request='{"contents":[{"parts":[{"text": "Write a git commit message title (no more than 72 characters total) for the following git diff: '"$diff"' Do not include any other text in the repsonse."}]}]}'
49
58
50
-
# Get commit message from Gemini API
51
-
commit_message=$(curl -s \
52
-
-H 'Content-Type: application/json' \
53
-
-d "$gemini_request" \
54
-
-X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=${GEMINI_API_KEY}" \
55
-
| jq -r '.candidates[0].content.parts[0].text'
56
-
)
59
+
## Get commit message from Gemini API
60
+
#commit_message=$(curl -s \
61
+
# -H 'Content-Type: application/json' \
62
+
# -d "$gemini_request" \
63
+
# -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=${GEMINI_API_KEY}" \
64
+
# | jq -r '.candidates[0].content.parts[0].text'
65
+
# )
57
66
58
-
# Clean up commit message formatting - remove #, ```, "", '', ()), and period . at the end of response
59
-
commit_message=$(echo $commit_message| sed 's/#//g'| sed 's/```//g'| sed 's/Commit message title://g'| sed 's/Commit message summary://g'| sed 's/\.//g'| sed 's/\"//g'| sed "s/'//g"| sed 's/())//g'| sed 's/()//g'| sed 's/Commit message://g'| sed 's/Commit message title: //g'| sed 's/Commit message summary: //g'| sed 's/Commit message body: //g'| sed 's/Commit message body://g')
67
+
## Clean up commit message formatting - remove #, ```, "", '', ()), and period . at the end of response
68
+
commit_message=$(echo $commit_message| sed 's/#//g'| sed 's/```//g'| sed 's/Commit message title://g'| sed 's/Commit message summary://g'| sed 's/\.//g'| sed 's/\"//g'| sed "s/'//g"| sed 's/())//g'| sed 's/()//g'| sed 's/Commit message://g'| sed 's/Commit message title: //g'| sed 's/Commit message summary: //g'| sed 's/Commit message body: //g'| sed 's/Commit message body://g'| sed 's/^\s*//;s/\s*$//'| sed 's/Code Review Request://g'| sed 's/Code Review://g'| sed 's/Summary of changes://g')
0 commit comments