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
|
## 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
|
requires: jq
|
||||||
|
|
||||||
> aicommit_groq is broken. Don't use.
|
|
||||||
|
|
||||||
### use
|
### use
|
||||||
|
Instead of
|
||||||
Change your
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export GIT_EDITOR="<path/to/>aicommit"
|
git commit -m "your message here"`
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git commit
|
aicommit
|
||||||
```
|
```
|
||||||
|
35
aicommit
35
aicommit
@ -3,8 +3,7 @@ set -e
|
|||||||
|
|
||||||
ARGS=("${@-}")
|
ARGS=("${@-}")
|
||||||
|
|
||||||
TMP_FILE="/tmp/aicommit_tmp"
|
TMP_FILE="/tmp/aicommit"
|
||||||
|
|
||||||
system=$(
|
system=$(
|
||||||
cat - <<EOF
|
cat - <<EOF
|
||||||
|
|
||||||
@ -15,6 +14,21 @@ Give detail for every change in the diff.
|
|||||||
EOF
|
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
|
if ! diff=$(git diff --cached); then
|
||||||
echo "Failed to get diff."
|
echo "Failed to get diff."
|
||||||
exit 1
|
exit 1
|
||||||
@ -27,12 +41,13 @@ message=$(
|
|||||||
".message = $(jq -R -s '@json' <<<"${message_cat}")"
|
".message = $(jq -R -s '@json' <<<"${message_cat}")"
|
||||||
)
|
)
|
||||||
|
|
||||||
echo ""
|
# trunk-ignore(shellcheck/SC2091)
|
||||||
echo "Please wait for AI reponse..."
|
# trunk-ignore(shellcheck/SC2310)
|
||||||
|
if $(hasFlag -r --reset); then
|
||||||
if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then
|
if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then
|
||||||
echo "Failed to reset conversation."
|
echo "Failed to reset conversation."
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
curl -s "https://infer.x64.world/chat" \
|
curl -s "https://infer.x64.world/chat" \
|
||||||
@ -40,14 +55,12 @@ curl -s "https://infer.x64.world/chat" \
|
|||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "${message}" | jq -r '.content | gsub("\""; "")' >"${TMP_FILE}"
|
-d "${message}" | jq -r '.content | gsub("\""; "")' >"${TMP_FILE}"
|
||||||
|
|
||||||
|
# trunk-ignore(shellcheck/SC2181)
|
||||||
if [[ 0 -ne $? ]]; then
|
if [[ 0 -ne $? ]]; then
|
||||||
echo "Failed to get response."
|
echo "Failed to get response."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat ".git/COMMIT_EDITMSG" >>"${TMP_FILE}"
|
git commit -e -m "$(cat "${TMP_FILE}")" && rm "${TMP_FILE}"
|
||||||
cat "${TMP_FILE}" >".git/COMMIT_EDITMSG"
|
|
||||||
|
|
||||||
rm "${TMP_FILE}"
|
popd >/dev/null
|
||||||
|
|
||||||
"${EDITOR}" "$@"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user