diff --git a/README.md b/README.md index 33b9cc7..d7981ba 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ Staging, committing, and pushing code is a repetative manual process. Writing de ## Table of Contents - [What this script automates](#what-this-script-automates) -- [User input required](#user-input-required) - [Requirements](#requirements) - [Installation](#installation) - [Usage](#usage) @@ -22,12 +21,6 @@ Staging, committing, and pushing code is a repetative manual process. Writing de | Git Push | Pushing local commits to remote branch with `git push`. | | Git Push Retry (Pull & Push) | If a push fails, the script will `git pull` from the remote branch and push again. | -## Alias Command - -| Name | Description | -| -------------- | -------------------------------------------------------- | -| Alias Command | The alias command to be used for the script: `cm`. | - ## Requirements | Name | Description | Link, Location, or Command | @@ -35,6 +28,7 @@ Staging, committing, and pushing code is a repetative manual process. Writing de | Terminal or Shell | A terminal or shell for configuring and running the script. | [Download Terminal](https://www.apple.com/macos/terminal/) | | `Git Bash` **\*Required for Windows** | Git Bash provides a Unix command line emulator for windows which can be used to run Git, shell commands, and much more. | [Download Git Bash](https://gitforwindows.org/) | | Google Gemini API Key | A Gemini API key is required to use Gemini AI to generate commit messages. | [Get Gemini API Key](https://www.getgemini.ai/) | +| Alias Command | The alias command to be used for the script: `cm`. | Bash profile (`.zshrc` or `.bash_profile`) | ## Installation diff --git a/git-commit-push-script.sh b/git-commit-push-script.sh index a7cd965..4a3fad9 100755 --- a/git-commit-push-script.sh +++ b/git-commit-push-script.sh @@ -17,7 +17,7 @@ diff=$(git diff --cached) diff=$(echo $diff | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed 's/\n/\\n/g') # Prepare the Gemini API request -gemini_request='{"contents":[{"parts":[{"text": "Write a git commit message (commit message title 72 character maximum and commit message summary 50 character maxiumum) for the following git diff: '"$diff"' The format should be as follows (without titles, back ticks, or markdown fomatting): (2 new lines) "}]}]}' +gemini_request='{"contents":[{"parts":[{"text": "Write a git commit message title (no more than 72 characters total) for the following git diff: '"$diff"' "}]}]}' # Get commit message from Gemini API commit_message=$(curl -s \ @@ -27,6 +27,9 @@ commit_message=$(curl -s \ | jq -r '.candidates[0].content.parts[0].text' ) +# Clean up commit message formatting - remove #, ``` +commit_message=$(echo $commit_message | sed 's/#//g' | sed 's/```//g' | sed 's/Commit message title://g' | sed 's/Commit message summary://g') + # Prepare and execute commit command git commit -S -m "$ticket $commit_message"