Skip to content

Commit

Permalink
Merge pull request #3 from wesleyscholl/ABC-1234
Browse files Browse the repository at this point in the history
Abc 1234
  • Loading branch information
wesleyscholl authored Sep 23, 2024
2 parents e8737c2 + e38a502 commit 8e91b5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -22,19 +21,14 @@ 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 |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| 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

Expand Down
5 changes: 4 additions & 1 deletion git-commit-push-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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): <commit message title> (2 new lines) <commit message summary>"}]}]}'
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 \
Expand All @@ -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"

Expand Down

0 comments on commit 8e91b5d

Please sign in to comment.