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
Copy file name to clipboardExpand all lines: git-commit-push-script.sh
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ diff=$(git diff --cached)
21
21
MODEL="mistral"
22
22
23
23
# Prepare the prompt
24
-
PROMPT=$(printf "You are an expert software engineer.\n\nYour job is to generate a concise, descriptive commit message from the following git diff.\nThe commit message MUST be 72 characters or less - this is a strict requirement.\nOnly return the commit message itself without quotes, explanations or additional text.\n\nGit diff:\n%s""$diff")
24
+
PROMPT=$(printf "You are an expert software engineer.\n\nYour job is to generate a short, descriptive commit message from the following git diff.\nOnly return the commit message, 72 characters maximum in length. Do not include any other text in the response.\n\nGit diff:\n%s""$diff")
25
25
26
26
# Run the model and capture output
27
27
COMMIT_MSG=$(echo "$PROMPT"| ollama run "$MODEL")
@@ -32,19 +32,19 @@ if [ -z "$COMMIT_MSG" ]; then
32
32
exit 1
33
33
fi
34
34
35
-
# Clean up commit message formatting - remove #, ```, period . at the end of response
36
-
commit_message=$(echo $COMMIT_MSG| sed 's/#//g'| sed 's/```//g'| sed 's/Commit message title://g'| sed 's/Commit message summary://g'| sed 's/\.//g')
35
+
# Clean up commit message formatting - remove #, ```, "", '', and period . at the end of response
36
+
commit_message=$(echo $COMMIT_MSG| 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")
37
37
38
-
# If the commit message is longer than 72 characters, truncate it
38
+
# If the commit message is longer than 72 characters, truncate at the last word boundary
0 commit comments