Magiccommit: Effortless Git Commits with AI
Project description
MagicCommits
Magiccommits: Effortless Git Commits with AI
Installation
Before you start using MagicCommits, make sure you have Python and pip installed. Then, you can install MagicCommits using pip:
pip install magiccommits
If you are using python3 then
pip3 install magiccommits
Before you can use MagicCommits, you'll need to configure it with your OpenAI API key. If you haven't already, you can retrieve your API key from OpenAI (Note: You may need to create an account and set up billing).
Set the OPENAI_KEY
mc config set OPENAI_KEY=<your-token>
This will create a .mc file in your home directory (~/.mc)
.
Usage
Execute magiccommits or mc
to generate the commit messages
Additional Options
Command | Example | Functionality | |
---|---|---|---|
1 | -t or --ticket |
mc -t PROJ-123 |
Set the ticket number for your commit message |
2 | -a or --add |
mc -a |
Perform a git add . operation before commit |
3 | -u or --update |
mc commit -u |
Perform a git add --update operation |
You can use these additional options to customize your commit messages and perform relevant Git operations as needed in your project workflow.
Demo: mc -a
Demo: copy message to clipboard
Configuration
You can use these keys to configure various aspects of the project. To set the value for a key, you must use the format key=value
when using the mc config set
command. To retrieve the values for these keys, you can use the mc config get
command, either for all values or a specific key.
Configuration Keys
OPENAI_KEY [Required]
- Description: This key is used to specify the OpenAI API key.
- Example Setting:
- To set the value:
mc config set OPENAI_KEY=sk-test
- To retrieve the value:
mc config get OPENAI_KEY
- To set the value:
locale [OPT]
- Description: This key defines the locale or language for text generation.
- Example Setting:
- To set the value:
mc config set locale=en
- To retrieve the value:
mc config get locale
- To set the value:
generate [OPT]
- Description: This key determines the number of commit message to generate.
- Example Setting:
- To set the value:
mc config set generate=4
- To retrieve the value:
mc config get generate
- To set the value:
type [OPT]
-
Description: This key specifies the type of commit generation.
-
Example Setting:
- To set the value:
mc config set type=conventional
- To retrieve the value:
mc config get type
- To set the value:
conventional
-
Explanation: Generates commit messages following the conventional commit format.
-
Example:
- Commit Message:
feat: add new feature
- Description: A conventional commit format with a type ("feat" for feature) and a brief description.
- Commit Message:
conventional-emoji
-
Explanation: Generates commit messages following the conventional commit format with added emojis.
-
Example:
- Commit Message:
feat: add new feature :sparkles:
- Description: A conventional commit format with an emoji (:sparkles:) for visual appeal and a type ("feat") with a brief description.
- Commit Message:
message
-
Explanation: Generates simple and concise commit messages.
-
Example:
- Commit Message:
Update README.md
- Description: A straightforward commit message with a focus on the action ("Update README.md").
- Commit Message:
message-emoji
-
Explanation: Generates simple commit messages with added emojis.
-
Example:
- Commit Message:
Fix a critical bug :bug:
- Description: A simple commit message with an emoji (:bug:) for visual context, describing the action ("Fix a critical bug").
- Commit Message:
proxy [OPT]
- Description: This key allows you to set a proxy server for network requests.
- Example Setting:
- To set the value:
mc config set proxy=http
- To retrieve the value:
mc config get proxy
- To set the value:
model [OPT]
- Description: This key defines the model to be used for commit generation.
- Example Setting:
- To set the value:
mc config set model=gpt-3.5-turbo
- To retrieve the value:
mc config get model
- To set the value:
timeout [OPT]
- Description: This key sets the maximum timeout (in milliseconds) for API requests.
- Example Setting:
- To set the value:
mc config set timeout=10000
- To retrieve the value:
mc config get timeout
- To set the value:
max_length [OPT]
- Description: This key specifies the maximum length of generated text.
- Example Setting:
- To set the value:
mc config set max_length=50
- To retrieve the value:
mc config get max_length
- To set the value:
max_token [OPT]
- Description: This key determines the maximum number of tokens in the generated text.
- Example Setting:
- To set the value:
mc config set max_token=200
- To retrieve the value:
mc config get max_token
- To set the value:
copy_commit [OPT]
- Description: This key is a boolean flag that determines whether to copy the generated text to the clipboard.
- Example Setting (True):
- To set the value:
mc config set copy_commit=True
- To retrieve the value:
mc config get copy_commit
- To set the value:
Getting Configuration Values
To retrieve the values for these configuration keys, you can use the following commands:
- To get all configuration values:
mc config get
Usage
Generate Commit Messages
You can use MagicCommits to effortlessly generate commit messages for your staged changes:
MagicCommits will analyze your Git diff and employ AI to suggest a commit message. You can then choose to commit, commit and push, or copy the message to your clipboard.
Version
To check the current version of MagicCommits, you can use the following command:
mc --version
Credits
MagicCommits is inspired by AI Commits, created by Hassan El Mghari.
Contributing
If you want to help fix a bug or implement a feature in Issues, checkout the Contribution Guide to learn how to setup project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Hashes for magiccommits-1.0.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 589b0934c1cbf623c83609c16dc95ff95f28d933679a6c2b5bbe85b6657786c7 |
|
MD5 | 8bc79f10a07149d40da8d92f154486af |
|
BLAKE2b-256 | 07d3a0a350d0a7f46ea8e109204a0d49b5ae7e13fe946b5b5ab7178b373af875 |