diff options
| author | allexanderbergmans <allexander.bergmans@student.elisa.be> | 2026-07-03 16:18:29 +0200 |
|---|---|---|
| committer | allexanderbergmans <allexander.bergmans@student.elisa.be> | 2026-07-03 16:18:29 +0200 |
| commit | e0142bd624cc090ee51a26fcdc48ff3451f29564 (patch) | |
| tree | 54b24c6b03ccb3070d48108f5eebe3e68fd1456e | |
| parent | 0952ff21b0fd30639b5c2de45e985d9be5f64e80 (diff) | |
fix(files): parse commit message correctlymain
| -rw-r--r-- | ai/Modelfile | 55 | ||||
| -rw-r--r-- | scripts/commit.sh | 25 |
2 files changed, 54 insertions, 26 deletions
diff --git a/ai/Modelfile b/ai/Modelfile index 3ffa32a..70eca35 100644 --- a/ai/Modelfile +++ b/ai/Modelfile @@ -1,27 +1,44 @@ -FROM qwen3:4b +FROM llama3.2:3b SYSTEM """ -You are a Git commit message generator. +You generate Git Conventional Commit messages. -Always output exactly one Conventional Commit message. +Thinking is disabled. + +Your response MUST consist of exactly one line. Rules: - Output ONLY the commit message. -- Format: <type>(<scope>): <description> -- Types: - feat - fix - docs - refactor - build - chore - test - perf - ci - revert -- Use imperative mood. -- Maximum 72 characters. -- No markdown. -- No explanations. +- Never explain your reasoning. +- Never output "Thinking". +- Never output markdown. +- Never output code fences. +- Never output multiple lines. +- Never ask questions. + +Format: +<type>(<scope>): <description> + +Allowed types: +feat +fix +docs +refactor +build +chore +test +perf +ci +revert + +Guidelines: +- Use the imperative mood. +- Keep the subject under 72 characters. - Choose an appropriate scope when possible (kernel, boot, arch, mm, vfs, fs, net, drivers, libc, docs, build). +- If no scope is appropriate, omit it. + +Examples: +feat(kernel): initialize scheduler +fix(vfs): prevent inode reference leak +docs: add contributing guide """
\ No newline at end of file diff --git a/scripts/commit.sh b/scripts/commit.sh index 50ce5fa..6c7597c 100644 --- a/scripts/commit.sh +++ b/scripts/commit.sh @@ -1,23 +1,34 @@ #!/usr/bin/env bash -set -e +set -euo pipefail if git diff --cached --quiet; then echo "No staged changes." exit 1 fi -MSG=$(git diff --cached | ollama run git-commit) +MSG=$( +git diff --cached \ +| ollama run git-commit \ +| sed '/^$/d' \ +| tail -n 1 +) + +COMMIT_RE='^(feat|fix|docs|refactor|build|chore|test|perf|ci|revert)(\([[:alnum:]_-]+\))?: .+$' + +if ! [[ $MSG =~ $COMMIT_RE ]]; then + echo "Invalid commit message:" + echo "$MSG" + exit 1 +fi echo echo "Generated commit message:" -echo "$MSG" +echo " $MSG" echo -read -p "Commit? [Y/n] " CONFIRM +read -rp "Commit? [Y/n] " CONFIRM -if [[ "$CONFIRM" =~ ^[Nn]$ ]]; then - exit 0 -fi +[[ "$CONFIRM" =~ ^[Nn]$ ]] && exit 0 git commit -m "$MSG"
\ No newline at end of file |
