Files
comma-scripts/,commit-and-push-self
lixulun 98dd086529 feat(commit-and-push-self): use llm to generate commit messages
- skip commit if no staged changes
- fallback to timestamp-based message if llm not available
- parse llm output as title + body (first line + lines after blank line)
2026-03-25 18:23:57 +08:00

17 lines
504 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
git add -A
if [ -z "$(git status --porcelain)" ]; then
exit 0
fi
if command -v llm &>/dev/null; then
COMMIT_MSG=$(git diff --staged | awk 'BEGIN{print "根据代码变更生成一个 git commit尽量简洁不废话如果有正文需要符合标题+空行+正文的规范。只返回结果"}1' | llm)
git commit -m "$(echo "$COMMIT_MSG" | head -n1)" -m "$(echo "$COMMIT_MSG" | tail -n +3)"
else
git commit -m "auto commit at $(date '+%Y-%m-%d %H:%M:%S')"
fi
git push