the-cafe / git-ai-commit

let AI write your commit messages
https://pypi.org/project/git-ai-commit/
51 stars 0 forks source link

create command to setup `prepare-commit-msg` hook independently #28

Closed ming1in closed 3 months ago

ming1in commented 3 months ago

Description

Introduce a set of commands that programmatically set the prepare-commit-msg hook script without using the pre-commit framework

Test Plan

build and install for latest changes. FYI, the pre-commit install step will overwrite the .git/hook/prepare-commit-msg

pip install . && pre-commit install && pre-commit autoupdate

Run the following command to setup the prepare-commit-msg git hook with the pre-install framework. This should prompt you to override the existing .git/hook/prepare-commit-msg if it already exists

> git_ai_commit hook --setup

Attempt to remove .git/hook/prepare-commit-msg

> git_ai_commit hook --remove

Do setup again

> git_ai_commit hook --setup

Attempt to commit a change from git cli, observe AI generated commit message if there is on user provided commit message

# expect an AI-generated commit message
git commit 

# the given message should be used for the commit
git commit -m "user provided commit message"

Follow up