Compare commits
No commits in common. "141b53b4ba324c20cd9e50b8835a7c4e89840e95" and "455ae71cd35a5fa0d66f6400f4b5e1185c1e3ad4" have entirely different histories.
141b53b4ba
...
455ae71cd3
12
README.md
12
README.md
@ -1,19 +1,15 @@
|
||||
## use AI to draft commit messages
|
||||
|
||||
aicommit injects a commit message draft written by RayAI before loading your default editor for review.
|
||||
clone this repo and then link the scripts into your path.
|
||||
|
||||
requires: jq
|
||||
|
||||
> aicommit_groq is broken. Don't use.
|
||||
|
||||
### use
|
||||
|
||||
Change your
|
||||
Instead of
|
||||
|
||||
```bash
|
||||
export GIT_EDITOR="<path/to/>aicommit"
|
||||
git commit -m "your message here"`
|
||||
```
|
||||
|
||||
```bash
|
||||
git commit
|
||||
aicommit
|
||||
```
|
||||
|
39
aicommit
39
aicommit
@ -3,8 +3,7 @@ set -e
|
||||
|
||||
ARGS=("${@-}")
|
||||
|
||||
TMP_FILE="/tmp/aicommit_tmp"
|
||||
|
||||
TMP_FILE="/tmp/aicommit"
|
||||
system=$(
|
||||
cat - <<EOF
|
||||
|
||||
@ -15,6 +14,21 @@ Give detail for every change in the diff.
|
||||
EOF
|
||||
)
|
||||
|
||||
pushd "$(pwd)" >/dev/null
|
||||
|
||||
hasFlag() {
|
||||
local flags=("$@")
|
||||
for var in "${ARGS[@]}"; do
|
||||
for flag in "${flags[@]}"; do
|
||||
if [[ ${flag} == "${var}" ]]; then
|
||||
echo 'true'
|
||||
return
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo 'false'
|
||||
}
|
||||
|
||||
if ! diff=$(git diff --cached); then
|
||||
echo "Failed to get diff."
|
||||
exit 1
|
||||
@ -27,12 +41,13 @@ message=$(
|
||||
".message = $(jq -R -s '@json' <<<"${message_cat}")"
|
||||
)
|
||||
|
||||
echo ""
|
||||
echo "Please wait for AI reponse..."
|
||||
|
||||
if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then
|
||||
echo "Failed to reset conversation."
|
||||
exit 1
|
||||
# trunk-ignore(shellcheck/SC2091)
|
||||
# trunk-ignore(shellcheck/SC2310)
|
||||
if $(hasFlag -r --reset); then
|
||||
if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then
|
||||
echo "Failed to reset conversation."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
curl -s "https://infer.x64.world/chat" \
|
||||
@ -40,14 +55,12 @@ curl -s "https://infer.x64.world/chat" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "${message}" | jq -r '.content | gsub("\""; "")' >"${TMP_FILE}"
|
||||
|
||||
# trunk-ignore(shellcheck/SC2181)
|
||||
if [[ 0 -ne $? ]]; then
|
||||
echo "Failed to get response."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat ".git/COMMIT_EDITMSG" >>"${TMP_FILE}"
|
||||
cat "${TMP_FILE}" >".git/COMMIT_EDITMSG"
|
||||
git commit -e -m "$(cat "${TMP_FILE}")" && rm "${TMP_FILE}"
|
||||
|
||||
rm "${TMP_FILE}"
|
||||
|
||||
"${EDITOR}" "$@"
|
||||
popd >/dev/null
|
||||
|
Loading…
Reference in New Issue
Block a user