Skip to content

Python utility script to write automated git commit messages using GPT-4. Can be set on a timer using a cron job for even more automation

License

Notifications You must be signed in to change notification settings

adamowada/auto-acp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto-ACP

by Adam Owada

❓ Tired of bland, unhelpful commit messages?

❓ Do you frequently forget to ACP and regret it later?

❓ Wish your commit graph had more commits??

🥳 Never fear! Auto-ACP is here! 🥳

Screenshot

Features:

  • Auto-ACP is a command-line interface application written in python that allows for quick and easy git add, commit, and pushes
  • Auto-ACP uses OpenAI's ChatGPT API to automatically generate a 1 line commit message
  • Once installed, simply run the command autoacp in your terminal. Auto-ACP will then:
    • git add -N .
    • git diff
    • Generate a commit message based on the output of git diff
    • git add .
    • git commit -m "<generated_commit_message>"
    • git push
    • Finally, Auto-ACP will print the generated commit message to the terminal
  • If there aren't changes to any files it will exit early. Helpful when setting Auto-ACP to a timer with watch!
  • View an entire commit history generated by Auto-ACP 👀

Prerequisites:

  • git
  • Python 3.10 or later, pip, and venv. Tutorial
  • Valid API key from OpenAI

Bash Installation Instructions: (pictures and more detail coming soon)

  1. Clone this repository
    • $ git clone [email protected]:adamowada/auto-acp.git
    • Optionally you may download as a zip or fork the repository
  2. Create a virtual environment in the root of your directory
    • $ cd auto-acp
    • $ python3.11 -m venv .venv
    • Optionally use an older version of python (it works with 3.10.6. No guarantees)
  3. Activate virtual environment
    • $ source .venv/bin/activate
  4. Pip install requirements
    • $ pip install -r requirements.txt
  5. Create an .env file in the root of your directory (same location as .env.sample)
    • $ touch .env
  6. Edit .env following the example of .env.sample and of course add your own personal API key
  7. Edit autoacp in a file editor of your choosing:
    1. Change line 1 the be the absolute path of your virtual environment's python
    2. Change line 10 to be the absolute path of your .env file
  8. Make the autoacp file an executable
    • $ chmod +x autoacp
  9. Add the root directory to your $PATH variable. The easiest way to do this is to add a line to the bottom of your .bashrc file
    • Example: export PATH=$PATH:/home/adam/projects/auto-acp
    • Restart your terminal
  10. Test by running $ autoacp in a git repository with uncommitted changes. If you see a commit message (and don't see errors) it works!
  11. 🎉 You did it! 🎉

Optional Step: Add a watch alias to your .bashrc:

  • Add this to the bottom of your .bashrc file:
aacp() {
    wait="$*"
    watch -n $wait autoacp
}
  • Then when you are working you can run $ aacp 60 which will use watch to autoacp every 60 seconds (or however many seconds you pass as an argument)

Known Issues:

  • Large diffs that cause the request to exceed 4096 tokens, which is approximately 16,000 characters, will fail
    • This can happen when many boilerplate files are created
  • Does a good job describing 'what' changes were made, but not the 'why' or 'how'
  • OpenAI's API is paid. Therefore while this app is free, using it will cost you money. Use at your own risk

TODO:

  • Add pictures to installation guide
  • Make installation easier
  • Add configuration option to match commit message style guides

About

Python utility script to write automated git commit messages using GPT-4. Can be set on a timer using a cron job for even more automation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages