Git Change Visualization Tool with AI-powered summaries
Project description
CommitLens - Git Change Visualization Tool
CommitLens is a powerful tool that provides natural language explanations of git diffs, making it easier to understand changes between branches or commits. It uses OpenAI's GPT models to generate clear, human-readable summaries of code changes.
Features
- Natural Language Explanations: Clear summaries of git diffs.
- Branch Comparison: Ability to compare any two branches in the repository.
- Uncommitted Changes Summary: Summary of current working directory changes.
- Commit Range Summary: Summary of changes from a specific commit to HEAD.
- Raw Diff Mode: View raw git diff with added statistics.
- Preview Mode: Check token count and estimated cost before sending to OpenAI.
- Markdown Formatting: Proper formatting and syntax highlighting in the terminal.
- Global Configuration: Persistent configuration using a config file.
- Model Selection: Choose between different OpenAI models.
Requirements
- Python 3.6+
- Git
- OpenAI API key (for natural language explanations)
Installation
Option 1: Clone the repository
git clone https://github.com/alessandrodorazio/commitlens.git
cd commitlens
pip install -r requirements.txt
Option 2: Install as a package
pip install commitlens
Or directly from the repository:
pip install git+https://github.com/alessandrodorazio/commitlens.git
Configuration
CommitLens offers two ways to configure your OpenAI API key:
1. Using the config command (Recommended)
After installing CommitLens, you can set your API key using the config command:
commitlens config --api-key your_api_key_here
You can also set the model to use:
commitlens config --model gpt-4
To view your current configuration:
commitlens config --show
This stores your configuration in ~/.commitlens/config.json with restricted permissions.
2. Using environment variables
You can set the API key as an environment variable:
export OPENAI_API_KEY=your_api_key_here
CommitLens will check these locations in the following order:
- Environment variables
- Config file in
~/.commitlens/config.json
Usage
Compare Two Branches
To compare two branches and get a natural language explanation of the differences:
commitlens compare feature-branch
This will compare feature-branch to your current branch.
You can also specify the base branch:
commitlens compare feature-branch main
or if you cloned the repository without installing:
./commitlens.py compare feature-branch main
Summarize Uncommitted Changes
To get a summary of your current uncommitted changes:
commitlens summary
You can also summarize changes from a specific commit to the current HEAD:
commitlens summary --from <commit-hash>
For example:
commitlens summary --from 797b3398a
This will show you a summary of all changes that have occurred since that commit.
Options
Both commands support the following options:
-
--raw: Show the raw git diff output instead of a natural language explanation. This option doesn't require an OpenAI API key. The raw output includes a summary of the total number of commits, files changed, and lines added/deleted. -
--preview: Show token count, estimated cost, diff statistics, and a list of commits without sending anything to OpenAI. This is useful to check how large the diff is, see which commits are included, and estimate the cost before proceeding with the natural language explanation. When using with--from, the list includes the starting commit. -
--no-color: Disable colored Markdown formatting in the terminal. By default, the tool renders the output with syntax highlighting and formatting.
License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Author
- Alessandro D'Orazio - GitHub
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file commitlens-0.1.0.tar.gz.
File metadata
- Download URL: commitlens-0.1.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8e5a63181eb270ec340a710aa853a6566f64d9420b98bb7a2eef3704367a075
|
|
| MD5 |
c988e1f677133e062fcade0b1fc2dd84
|
|
| BLAKE2b-256 |
eac15078857c24903f37b717f6050afc9b9fb3784ee3fc38771d4566245553b6
|
Provenance
The following attestation bundles were made for commitlens-0.1.0.tar.gz:
Publisher:
python-publish.yml on alessandrodorazio/commitlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
commitlens-0.1.0.tar.gz -
Subject digest:
b8e5a63181eb270ec340a710aa853a6566f64d9420b98bb7a2eef3704367a075 - Sigstore transparency entry: 174197038
- Sigstore integration time:
-
Permalink:
alessandrodorazio/commitlens@5958a64686d6a12b03d269539b0a84fe31c1de94 -
Branch / Tag:
refs/tags/published - Owner: https://github.com/alessandrodorazio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5958a64686d6a12b03d269539b0a84fe31c1de94 -
Trigger Event:
release
-
Statement type:
File details
Details for the file commitlens-0.1.0-py3-none-any.whl.
File metadata
- Download URL: commitlens-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dfd34309f0021f3a65ab0936870b2b59e3e804a6f5cac220494028ea0bda5f8
|
|
| MD5 |
ab60624898584056f41f9718d224fa67
|
|
| BLAKE2b-256 |
4f5da1169366992bcc7f34a8cb51aee11eec40af8e4e81490065176fb2388891
|
Provenance
The following attestation bundles were made for commitlens-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on alessandrodorazio/commitlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
commitlens-0.1.0-py3-none-any.whl -
Subject digest:
0dfd34309f0021f3a65ab0936870b2b59e3e804a6f5cac220494028ea0bda5f8 - Sigstore transparency entry: 174197040
- Sigstore integration time:
-
Permalink:
alessandrodorazio/commitlens@5958a64686d6a12b03d269539b0a84fe31c1de94 -
Branch / Tag:
refs/tags/published - Owner: https://github.com/alessandrodorazio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5958a64686d6a12b03d269539b0a84fe31c1de94 -
Trigger Event:
release
-
Statement type: