Autocommit is a Python module that leverages the power of GPT-3.5-turbo model from OpenAI to generate sophisticated, high-level git commit messages based on the changes you make in your codebase.
Instead of focusing on granular details or specific files/functions/classes, this module creates commit descriptions that encapsulate the broader impact of your changes from a user's perspective. This means clearer, more understandable commit history and less time spent crafting commit messages!
For example, instead of writing "Refactored function x in File y", autocommit will generate something like "Improved site performance".
The script reads the diff output for staged changes and generates a commit message that reflects the high-level effects of those changes.
These commit messages aim to be succinct (maximum 30 words), written in modern British English, and avoid sounding robotic. The tool avoids starting sentences with connective words like "Also", "Finally" etc.
git clone https://github.com/lightningorb/autocommit.git
cd autocommit
pip3 install .
hash -r
Once you've staged your git changes, run the Python script:
autocommit
Autocommit will output a suggested commit message and ask for your confirmation ("OK y/n: "
). If you're happy with the suggestion, simply type y
and press enter. The script will then make the git commit using the generated message.
If you aren't satisfied with the suggested commit message, enter n
and run the script again for a new suggestion.
Here are some examples of the type of commit messages generated by this module:
- "Updated site."
- "Xcode 14.3.1 IOS launch issues"
- "Fixed a crash when restarting from Connector. Resolved HTLCs animations typing issue, and missing field. Balanced ratio line is now easier to see."
- "Move all apps into the 'apps' dropdown, and disable app store #10"
- "Don't unmount after install (reduce risk of failure)"
Go ahead and try it out for yourself!
You must set your OpenAI API key as an environment variable OPEN_API_KEY
to allow the script to access the GPT-3.5-turbo model.
- Python 3.x
- An active OpenAI account and API key
- use tiktoken for token calculation, to not go over the maximum token limit.