Created
March 25, 2023 18:52
-
-
Save gigq/2f72a1f5a580f58069c0758c1778b960 to your computer and use it in GitHub Desktop.
Quick bash script using gpt-ai (https://github.com/lmatosevic/chatgpt-cli) to read git diff and create a commit message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git add . | |
# Run git diff and capture the output, excluding yarn.lock for js/ts projects | |
diff_output=$(git diff HEAD -- . ':(exclude)yarn.lock') | |
# Prepend the commit message to the diff output | |
commit_message="Output just a properly formatted git commit message from the following, be accurate and concise, no need to specify prefixes, don't assume why changes were made:" | |
full_output="$commit_message\n\n$diff_output" | |
chatgpt_message=$(gpt-ai "$full_output") | |
# Send the commit message to git | |
git commit -a -m "$chatgpt_message" -e | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment