ChatGPT Powered Auto Committer

Or as I like to call it, The Github Button

Project goal-

The GitHub Button was a personal project I began towards the start of my time at University. The goal was to make a one button solution that can commit to GitHub for me completely autonomously including commit summary and title writing using ChatGPT.

Processes-

The first thing I had to do was work out how to interface with the ChatGPT api. This was made easy thanks to the OpenAi package for python which allowed me to easily create sessions with the api. Once this was done I began working on a system to find the differences from each commit.

In theory this is really easy to do as you can just use the git diff command to get a nice neat list of all the changes. However there's one big issue with this being how do we get the path of the active repository. GitHub Desktop has no way of interfacing with it externally so it will be extremely difficult to get this information. If the GitHub button was integrated in an IDE we could just look for the Git file in that directory but as it will be completely standalone this is not possible. After a lot of research I found that I could use the open in terminal shortcut of GitHub desktop and just copy and paste the path to the repo from there.

The code used for splitting requests based on tokens to use the better/cheaper models for them-

The code used for splitting requests based on tokens to use the better/cheaper models for them-

Next I had to give ChatGPT all of this information. After a few weeks of experimenting with test data I managed to get it to do pretty consistently useful outputs by modifying the system prompt. When a commit is made ChatGPT receives the code of the modified file along with a list of changes and instructions on how to interpret it. This all allows ChatGPT to generate relevant commit summaries.

This image shows one of the summaries and titles written by The GitHub Button

This image shows one of the summaries and titles written by The GitHub Button-

The next step is optimising all of this by counting how many tokens a request would be and changing models or splitting the request in correspondence to this. This allowed the program to run faster and work on much larger programs and changes. Next I implemented a GUI and allowed the program to run in the system tray. With this I also added a logging system and a configuration utility so users could input their file paths and api keys to use the program. Finally everything is compiled using pyinstaller and an installer is made using Inno Script.

However this was not without issues. I quickly realised that I needed a way to update the program when I made changes or users would be stuck with outdated mostly broken versions. My solution to this was to write the versions of each of its separate scripts to a file and then compare these to an update file hosted on my website. If they didn't match it would prompt the user to update their software. During this testing I discovered many issues, a big one being that the shortcut to open a repository in terminal changes based both on Windows version and keyboard layout. My solution to this was to find the shortcut keys in Windows 10 and 11 along with standard US and UK keyboard layouts and leave it at that for now.

An image of the physical GitHub Button plugged in and working

An image of the physical GitHub Button plugged in and working. Microcontroller code by Dexter-

Final product-

https://github.com/AlfieRichards/AutoComitter

Evaluation-

Overall I am really happy with this project as it really tested my abilities as a programmer and developer and had a lot of firsts for me in it. It was also clearly a good idea as a few months later Microsoft implemented an almost identical system into Visual Studio. This system includes a few of my proposed changes such as allowing the user to provide additional context however other than that it is almost exactly the same. Interestingly mine still seems to be able to produce more concise and accurate titles along with working alongside any software and not just Visual Studio which is definitely an advantage.

An apple inspired trailer for The GitHub Button-