Skip to content

Abc 1234 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2931478
TEST-1234 Fix: Remove template string from Gemini API request
wesleyscholl Sep 23, 2024
82087d3
TEST-1234 ```
wesleyscholl Sep 23, 2024
091de7d
TEST-1234 ## Fix: Remove markdown from Gemini API request
wesleyscholl Sep 23, 2024
f2e44d4
TEST-1234 Commit message title
wesleyscholl Sep 23, 2024
18e869b
TEST-1234 Fix Improve Gemini API request for commit messages
wesleyscholl Sep 23, 2024
6c22010
TEST-1234 Refactor: Remove unnecessary sed command Remove the third …
wesleyscholl Sep 23, 2024
c1ca246
TEST-1234 Fix: Escape double quotes in Gemini API request Escape dou…
wesleyscholl Sep 23, 2024
d5cf944
TEST-1234 Fix: Add new line escape to commit message Escape newline c…
wesleyscholl Sep 23, 2024
21179be
TEST-1234 feat: improve Gemini API commit message request This commit…
wesleyscholl Sep 23, 2024
43b6821
TEST-1234 feat: Remove unnecessary newlines from commit message reque…
wesleyscholl Sep 23, 2024
de096ed
TEST-1234 Fix: Adjust commit message request for Gemini API This comm…
wesleyscholl Sep 23, 2024
df5670c
TEST-1234 Commit message title: Improve commit message generation C…
wesleyscholl Sep 23, 2024
0b0b39e
TEST-1234 Fix: Add newlines after period in commit message Fix: Adds …
wesleyscholl Sep 23, 2024
2aff2e6
TEST-1234 Refactor: Remove commit summary from Gemini request
wesleyscholl Sep 23, 2024
4d5ec6f
TEST-1234 Refactor: Improve commit message formatting
wesleyscholl Sep 23, 2024
cdf82de
TEST-1234 Refactor: Improve commit message extraction
wesleyscholl Sep 23, 2024
475ac7e
ABC-1234 ## Fix: Update README.md table of contents
wesleyscholl Sep 23, 2024
105d134
ABC-1234 ## Add Gemini API Key to Requirements
wesleyscholl Sep 23, 2024
c9b914a
ABC-1234 Refactor: Remove commit message summary generation This comm…
wesleyscholl Sep 23, 2024
e38a502
ABC-1234 Fix: Change commit message title length wording
wesleyscholl Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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