From 98dd08652911c1bb6d2029b4f1efa96a80c95143 Mon Sep 17 00:00:00 2001 From: lixulun Date: Wed, 25 Mar 2026 18:23:57 +0800 Subject: [PATCH] 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) --- ,commit-and-push-self | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/,commit-and-push-self b/,commit-and-push-self index 2f14c1a..ce0bd3e 100755 --- a/,commit-and-push-self +++ b/,commit-and-push-self @@ -1,6 +1,16 @@ #!/usr/bin/env bash -set -e git add -A -git commit -m "auto commit at $(date '+%Y-%m-%d %H:%M:%S')" + +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