the-cafe / git-ai-commit

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

Avoid overriding any existing commit message from the user #20

Closed ming1in closed 3 months ago

ming1in commented 3 months ago

Description

This PR patches an issue where the git hook overrides existing commit messages with the AI generated one.

The proposed patch involves checking the ./.git/COMMIT_EDITMSG before we continue to the generation logic. If the file is empty we infer that there is no existing commit message and the other way around

Test Plan

Build and install to obtain the latest changes

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

Attempt a commit with an empty message, and expect our AI-generated commit to show up in the editor

git commit

Attempt a commit with a message, and expect to continue the commit with that manually typed message

git commit -m "manually typed commit msg"