summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorache <ache@ache.one>2025-12-24 19:08:42 +0100
committerache <ache@ache.one>2025-12-24 19:08:42 +0100
commita4eaa1e9c94780b61a89a93cf911f6893ecf502a (patch)
tree759ca0b7d0c7a337f6c41accd98fce7c18c46010 /functions
parentfeat: add new utility for generating professional commit messages from git diff (diff)
feat: Implement 'ia-commit' utility for generating professional git commit messages from a diff
The changes made include deleting the old 'ia-commit-message' function and creating a new one called 'ia-commit'. This new function utilizes a language model to generate a commit message based on the staged git diff. It then asks the user to confirm or edit the generated message before committing it.
Diffstat (limited to 'functions')
-rwxr-xr-xfunctions/ia-commit-message.fish7
-rwxr-xr-xfunctions/ia-commit.fish27
2 files changed, 27 insertions, 7 deletions
diff --git a/functions/ia-commit-message.fish b/functions/ia-commit-message.fish
deleted file mode 100755
index acd3ffd..0000000
--- a/functions/ia-commit-message.fish
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/fish
-
-# Utility that will Prompt a LLM to make a commit message from a git diff.
-
-function ia-commit-message
- echo -e "Write a professional git commit message based on the a diff below. \nDo not preface the commit with anything, use the present tense, return the full sentence, and use the conventional commits specification (<type in lowercase>: <subject>)\n\n-----\n\n$(git diff --staged)" | hailper -p b-code | tee /tmp/prev-ia-commit-message
-end
diff --git a/functions/ia-commit.fish b/functions/ia-commit.fish
new file mode 100755
index 0000000..d47cca6
--- /dev/null
+++ b/functions/ia-commit.fish
@@ -0,0 +1,27 @@
+#!/bin/fish
+
+# Utility that will Prompt a LLM to make a commit message from a git diff.
+
+function _ask
+ echo "Is it correct ?! (y/n/e/1/r/)"
+ read response
+
+ if [ $response = y ]
+ git commit -F /tmp/prev-ia-commit-message
+ else if [ $response = 1 ]
+ git commit -m (cat /tmp/prev-ia-commit-message | head -n 1)
+ else if [ $response = e ]
+ $EDITOR /tmp/prev-ia-commit-message
+ cat /tmp/prev-ia-commit-message | head -n 1
+ _ask
+ else if [ $response = r ]
+ ia-commit
+ end
+end
+
+function ia-commit
+ echo -e "Write a professional git commit message based on the a diff below. \nDo not preface the commit with anything, use the present tense, return the full sentence, and use the conventional commits specification (<type in lowercase>: <subject>)\n\n-----\n\n$(git diff --staged)" | hailper -p b-code | tee /tmp/prev-ia-commit-message
+ _ask
+ rm /tmp/prev-ia-commit-message 2>/dev/null
+
+end