|
3 dias atrás | |
---|---|---|
Dockerfile | 3 dias atrás | |
LICENSE | 3 dias atrás | |
Makefile | 3 dias atrás | |
README.md | 3 dias atrás | |
ai-rebase.sh | 3 dias atrás | |
git_rebase_ai.py | 3 dias atrás |
This tool leverages the Google Gemini API to assist with interactive Git rebases by suggesting fixup
and reword
operations.
mkdir -p ~/bin && curl -fLRo ~/bin/ai-rebase.sh https://raw.githubusercontent.com/senomas/git-auto-rebase/refs/heads/master/ai-rebase.sh && chmod +x ~/bin/ai-rebase.sh
fixup
operations for commits that appear to be minor corrections to their predecessors.reword
operations) for commits that don't follow conventions or lack clarity.Build the Docker Image: Build manually:
docker build -t docker.senomas.com/git-rebase:1.0 .
(Note: The tag docker.senomas.com/git-rebase:1.0
is used by default in ai-rebase.sh
. You can override it using the DOCKER_IMAGE_NAME
environment variable if needed, e.g., export DOCKER_IMAGE_NAME=my-custom-image:latest
.)
Set Environment Variables: Export your Gemini API key:
export GEMINI_API_KEY='YOUR_API_KEY'
Optionally, set the Gemini model to use (defaults to gemini-1.5-flash-latest
if not set):
export GEMINI_MODEL='gemini-1.5-pro-latest' # Or another compatible model
(Replace YOUR_API_KEY
with your actual key. Add these lines to your shell profile (e.g., .bashrc
, .zshrc
, config.fish
) for persistence.)
Run the ai-rebase.sh
script directly.
ai-rebase.sh
DirectlyThe ai-rebase.sh
script runs the git_rebase_ai.py
script inside a Docker container to perform the analysis and rebase operations.
# Compare against upstream/master (default) and attempt auto-rebase (fixup then reword)
./ai-rebase.sh
# Compare against origin/develop and attempt auto-rebase
./ai-rebase.sh origin/develop
# Compare against upstream/main, show instructions only (no auto-rebase)
./ai-rebase.sh --instruct
# Compare against origin/develop, show instructions only
./ai-rebase.sh origin/develop --instruct
# Delete backup branches created by the tool for the current branch
./ai-rebase.sh --delete-backups
Rebase (Fixup & Reword):
git status
)../ai-rebase.sh [upstream_ref] [--instruct] [--delete-backups]
.upstream_ref
(defaults to upstream/main
) and your current branch (HEAD
).fixup
operations.--instruct
is NOT used:your-branch-backup-TIMESTAMP
).git rebase -i
non-interactively using a generated script to apply the fixups.--instruct
IS used:--instruct
was used)
upstream_ref
and HEAD
.reword
operations with the new messages.--instruct
is NOT used (and Phase 1 auto-fixup succeeded):git rebase -i
non-interactively using generated scripts to mark commits for reword and supply the new messages.--instruct
IS used:ai-rebase.sh
script is the main entry point.git_rebase_ai.py
script inside the specified Docker container (docker.senomas.com/git-rebase:1.0
by default).pwd
) as /repo
, .gitconfig
, and .git-credentials
(read-only) into the container.GEMINI_API_KEY
and GEMINI_MODEL
environment variables into the container.upstream_ref
, --instruct
, --delete-backups
) to the Python script.git_rebase_ai.py
:
upstream_ref
, --instruct
, --delete-backups
).--delete-backups
if present.git merge-base
).REQUEST_FILES: [...]
), to suggest FIXUP: ... INTO ...
lines.--instruct
, creates backup, confirms, and attempts automatic fixup rebase using GIT_SEQUENCE_EDITOR
script. Handles potential failures and aborts. If successful, proceeds.--instruct
, stores suggestions and proceeds.--instruct
)
REWORD: ... NEW_MESSAGE: ... END_MESSAGE
blocks.--instruct
, confirms, and attempts automatic reword rebase using GIT_SEQUENCE_EDITOR
(changes pick
to r
) and GIT_EDITOR
(supplies new message via env var) scripts. Handles potential failures and aborts.--instruct
, prints combined manual instructions (fixup + reword).ai-rebase.sh
: Main entry script that runs the Python script in Docker.git_rebase_ai.py
: Handles AI rebase fixup and reword suggestions and automation.Dockerfile
: Defines the Docker image environment.README.md
: This file.