Skip to content

4rgon4ut/gemmit

Repository files navigation

gemmit

A command-line tool that uses the gemini-cli to generate Git commit messages from your staged changes.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/gemmit.git
    cd gemmit
  2. Install:

     pip install .
  3. Update your shell profile:

    Add the following line to your ~/.bashrc, ~/.zshrc, or other shell profile:

    export PATH="$HOME/.gemmit:$PATH"

Usage

gemmit [options] <template>

Uninstallation

To remove gemmit and its configuration from your system, follow these steps:

  1. Uninstall the package:

    pip uninstall gemmit
  2. Remove the configuration directory:

    rm -rf ~/.gemmit

Privacy Note

gemmit works by sending the output of git diff --cached (your staged changes) to the local gemini-cli agent to generate a commit message. Be mindful of this when staging sensitive information.

Interactive Mode

By default, gemmit runs in an interactive mode that allows you to review, edit, or regenerate the commit message before committing.

--- Generated Commit Message ---
feat: Add interactive commit message workflow

The previous implementation was a simple, one-shot operation that
generated a commit message, leaving the user to either accept it
as-is or abort.
This patch introduces a new interactive workflow for commit message
generation, providing a more powerful and user-friendly experience.

The key changes are:
- The `generate` command now enters an interactive loop after creating
  the first message.
- Four options are provided:
  - [Y]es: Accept the message and proceed with the commit.
  - [E]dit: Open the message in the default system editor ($EDITOR)
    for manual changes.
  - [R]egenerate: Discard the current message and generate a new one.
  - [N]o: Abort the commit process.
- The main script invokes this interactive mode by default.
--------------------------------
Use this message? [Y]es, [E]dit, [R]egenerate, [N]o:
  • [Y]es: Accepts the message and commits.
  • [E]dit: Opens the message in your default text editor for manual changes.
  • [R]egenerate: Generates a new message using the same template.
  • [N]o: Aborts the commit.

Note: The "Edit" feature relies on the $EDITOR environment variable. Make sure it is configured in your shell profile (e.g., export EDITOR=vim). If it's not set, it will default to vim.

Options

Flags can be combined (e.g., -apy).

  • -a: Stage all tracked files (git add .) before generating the message.
  • -p: Push changes to the remote repository (origin <branch>) after a successful commit.
  • -y: (YOLO mode) Skip the interactive confirmation and commit directly.
  • -h: Show the help message.

Examples

1. Basic Commit

Stage your files manually, then generate a commit message using the kernel template.

# Stage your changes
git add src/gemmit.py

# Generate the commit message
gemmit kernel

2. Stage, Commit, and Push

An end-to-end workflow: stage all files, generate and confirm the message, and push to the remote repository.

# combined --add --push --yes
gemmit -apy kernel

Default Template

If you omit the <template> argument, gemmit will use the default_template specified in your ~/.gemmit/config.json file. The initial default is kernel.

Configuration

You can customize templates and behavior by editing ~/.gemmit/config.json.

  • templates: Define your own templates with custom prompts.
  • default_template: Set the template to be used by default when no template is specified.
  • autoconfirm: Set to true to make the -y flag the default behavior.
  • highlight_color: Set a hex color code (e.g., #FFA500) for gemmit's output.

About

Tool to generate commit messages using the gemini-cli

Resources

License

Stars

Watchers

Forks

Packages

No packages published