Application designed as a prepare-commit-msg
git hook that analyzes your staged files and generates a commit message without AI bullshit!
go install github.com/burgr033/autoCommit@latest
create a prepare-commit-msg
file in your git repository under .git/hooks/
directory and put in the following (as an example):
#!/bin/bash
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
CUSTOM_HEADER="# This is an autogenerated commit message"
CUSTOM_FOOTER="# powered by github.com/burgr033/autoCommit"
# Only proceed if no commit message was explicitly provided (-m or -F options)
if [[ -z "$COMMIT_SOURCE" ]]; then
autoCommit $COMMIT_MSG_FILE $CUSTOM_HEADER $CUSTOM_FOOTER
fi
Note
this could also be done in a git template. See https://git-scm.com/docs/git-init#_template_directory
- Pattern matching for file names for special files like
.gitlab-ci.yml
ordocs/*
- Descriptive comments, depending on git operation
- if pattern matching for files does not bring up a result the branch name is checked for a possible "git flow" naming.
The repo with the following git status
on a branch called feature/loremipsum
:
A .gitlab-ci.yml
A README.MD
MM internal/filetypes/filetypes.go
MM main.go
?? COMMIT_EDITMSG
?? test.txt
generates the following commit message:
# This is an automated commit message
# docs: added README.MD
# unknown: modified internal/filetypes/filetypes.go, main.go
# ci: added .gitlab-ci.yml
# This is the Footer of the automated commit message