tak-bro / aicommit2

A Reactive CLI that generates git commit messages with Ollama, ChatGPT, Gemini, Claude, Mistral and other AI
https://www.npmjs.com/package/aicommit2
MIT License
156 stars 12 forks source link

Allow flag to indicate manually being called in a git hook #94

Open devshorts opened 2 weeks ago

devshorts commented 2 weeks ago

Feature request

The current code looks to determine if it's a git hook from the calling process name, however if you already have a git hook and want to chain them together (for example, prepending a Jira ticket name parsed from the branch name) then the hook's can't be staged together gracefully.

Ideally the cli would take a flag that you could indicate "--hook-mode" or something which then allows the auto generation of the commits without falling into a STDIN mode that isn't workable during a git hook

Why?

see request

Alternatives

No response

Additional context

No response

tak-bro commented 1 week ago

@devshorts Thank you for raising this issue. Do you mean that add --hook-mode flag so you can chain hooks like this in the prepare-commit-msg file?

#!/bin/bash

COMMIT_EDITMSG_FILE_PATH=$1
DEFAULT_COMMIT_MSG=$(cat $COMMIT_EDITMSG_FILE_PATH)
CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
ISSUE_TICKET=$(echo "$CURRENT_BRANCH_NAME" | sed 's/.*\///')

echo "[#$ISSUE_TICKET] $DEFAULT_COMMIT_MSG" > $COMMIT_EDITMSG_FILE_PATH

...
aicommit2 --hook-mode
devshorts commented 1 week ago

Yes exactly! This would be really slick On Nov 10, 2024, at 9:09 PM, Tak @.***> wrote: @devshorts Thank you for raising this issue. Do you mean that add --hook-mode flag so you can chain hooks like this in the prepare-commit-msg file?

!/bin/bash

COMMIT_EDITMSG_FILE_PATH=$1 DEFAULT_COMMIT_MSG=$(cat $COMMIT_EDITMSG_FILE_PATH) CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) ISSUE_TICKET=$(echo "$CURRENT_BRANCH_NAME" | sed 's/.*\///')

echo "[#$ISSUE_TICKET] $DEFAULT_COMMIT_MSG" > $COMMIT_EDITMSG_FILE_PATH

... aicommit2 --hook-mode

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>