|
6 ngày trước cách đây | |
---|---|---|
Dockerfile | 6 ngày trước cách đây | |
README.md | 6 ngày trước cách đây | |
ai-commit.sh | 6 ngày trước cách đây | |
git_commit_ai.py | 6 ngày trước cách đây |
This tool automatically generates Git commit messages based on your staged changes using the Google Gemini API. It analyzes the diff of your staged files and suggests a commit message following conventional commit standards.
Build the Docker Image:
docker build -t docker.senomas.com/commit:1.0 .
(Note: The tag docker.senomas.com/commit:1.0
is used in the ai-commit.sh
script. You can change it if needed, but make sure to update the script accordingly.)
Set Environment Variable: Export your Gemini API key as an environment variable:
export GEMINI_API_KEY='YOUR_API_KEY'
(Replace YOUR_API_KEY
with your actual key. You might want to add this line to your shell profile (e.g., .bashrc
, .zshrc
, config.fish
) for persistence.)
git add
to stage the files you want to include in the commit.Run the script: Execute the ai-commit.sh
script from the root of your Git repository:
./ai-commit.sh
Review and Confirm: The script will:
y/n
).Commit: If you confirm ('y'), the script will create the commit using the generated message. If you decline ('n'), the commit will be aborted.
ai-commit.sh
script runs the git_commit_ai.py
script inside a Docker container (docker.senomas.com/commit:1.0
).pwd
) as /repo
inside the container, allowing the script to access your Git repository..gitconfig
and .git-credentials
(read-only) for Git operations within the container.GEMINI_API_KEY
environment variable into the container.git_commit_ai.py
script:
git diff --staged
.git commit -m "..."
with the generated message.git_commit_ai.py
: The main Python script that interacts with Git and the Gemini API.Dockerfile
: Defines the Docker image environment.ai-commit.sh
: A helper script to easily run the tool in Docker.README.md
: This file.