Metadata-Version: 2.4
Name: git-commit-gen
Version: 0.1.2
Summary: A tool to generate conventional commit messages using Gemini API
Project-URL: repository, https://github.com/salnika/git-commit-gen
Project-URL: homepage, https://github.com/salnika/git-commit-gen
License: Copyright (c) 2025
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.8
Requires-Dist: google-generativeai>=0.5.0
Requires-Dist: pygit2>=1.12.0
Requires-Dist: python-dotenv>=1.0.0
Description-Content-Type: text/markdown

# Git Commit Gen
[![PyPI version](https://badge.fury.io/py/git-commit-gen.svg)](https://pypi.org/project/git-commit-gen/)
[![Build Status](https://github.com/salnika/ai-commit-message/actions/workflows/deploy.yml/badge.svg)](https://github.com/salnika/ai-commit-message/actions)

A command-line tool to automatically generate concise and informative commit messages following the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) using the Google Gemini API.

## Features
- Analyzes staged Git changes (modified, added, and deleted files).
- Generates commit messages based on file diffs and changes.
- Ensures messages adhere to Conventional Commits format (e.g., `feat: add new feature`).
- Falls back to standard `git commit` if generation fails.

## Installation

Install the package via pip:

```bash
pip install git-commit-gen
```

### Prerequisites
- Python 3.8 or higher
- Git installed and configured
- A Google Gemini API key (see [Configuration](#configuration))

## Usage

Run the tool in a Git repository with staged changes:

```bash
git-commit-gen
```

You can pass additional Git commit options:

```bash
git-commit-gen --amend
git-commit-gen -v
```

The tool will:
1. Analyze your staged changes.
2. Generate a commit message using the Gemini API.
3. Warn if the message doesn't follow Conventional Commits.
4. Execute the commit with the generated message.

## Configuration

The tool requires a Google Gemini API key. Set it in a `.env` file in your working directory or as an environment variable:

### Using a `.env` file
Create a `.env` file in your project root:

```
GEMINI_API_KEY=your_api_key_here
```

### Using environment variables
Set the key in your shell:

```bash
export GEMINI_API_KEY=your_api_key_here
```

Optional environment variables:
- `GEMINI_MODEL`: Specify the Gemini model (default: `gemini-2.0-flash-001`).
- `MAX_DIFF_SIZE`: Maximum diff size to include in the prompt (default: `2000`).

## Example

1. Stage some changes:
   ```bash
   git add .
   ```

2. Run the tool:
   ```bash
   git-commit-gen
   ```

3. Output might look like:
   ```
   feat: implement user authentication
   ```

If the generated message doesn't follow Conventional Commits:
   ```
   Warning: Generated commit message may not follow Conventional Commits.
   It is recommended to review and adjust the message before committing.
   Proposed message: update readme file
   ```

## Development

### Project Structure
```
git_commit_gen/
├── git_commit_gen/
│   ├── __init__.py
│   └── git_commit_gen.py
├── pyproject.toml
└── README.md
```

### Build the Package
To build locally:
```bash
pip install hatchling build
python -m build
```

### Install Locally
```bash
pip install dist/git_commit_gen-0.1.0-py3-none-any.whl
```

## Contributing
Feel free to submit issues or pull requests on the [GitHub repository](https://github.com/Salnika/ai-commit-message)

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments
- Built with [Google Gemini API](https://developers.google.com/gemini).

