Skip to content

Commit 41a033c

Browse files
committed
chore: enable JSON dependencies and refine documentation
- uncomment serde and serde_json dependencies to support JSON output - remove duplicate dependency entries in Cargo.toml - add debug=false to release profile for optimized builds - bump package version to 1.5.2 for patch release - rephrase README sections for improved clarity and consistency - update features list and configuration examples in README.md - enhance Docker and git hook usage instructions in README.md Signed-off-by: mingcheng <[email protected]>
1 parent ed746a0 commit 41a033c

File tree

4 files changed

+44
-59
lines changed

4 files changed

+44
-59
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
1010

1111
[[package]]
1212
name = "aigitcommit"
13-
version = "1.5.1"
13+
version = "1.5.2"
1414
dependencies = [
1515
"arboard",
1616
"askama",

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aigitcommit"
3-
version = "1.5.1"
3+
version = "1.5.2"
44
edition = "2024"
55
description = "A simple git commit message generator by OpenAI compaction model."
66
license-file = "LICENSE"
@@ -27,8 +27,8 @@ askama = "0.12"
2727
async-openai = "0.29"
2828
git2 = "0.20"
2929
tokio = { version = "1.48.0", features = ["full"] }
30-
#serde = { version = "1.0", features = ["derive"] }
31-
#serde_json = "1.0"
30+
serde = { version = "1.0", features = ["derive"] }
31+
serde_json = "1.0"
3232
log = "0.4"
3333
#strum = "0.27.1"
3434
#strum_macros = "0.27.1"
@@ -38,8 +38,6 @@ tracing = "0.1"
3838
tracing-subscriber = "0.3"
3939
arboard = "3.6"
4040
tabled = "0.20"
41-
serde_json = "1.0.145"
42-
serde = { version = "1.0.228", features = ["derive"] }
4341

4442
[[bin]]
4543
name = "aigitcommit"
@@ -51,6 +49,7 @@ opt-level = "z"
5149
lto = true
5250
codegen-units = 1
5351
panic = "abort"
52+
debug = false
5453

5554
[build-dependencies]
5655
built = "0.8"

README.md

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
![screenshots](./assets/screenshots.png)
77

8-
A simple tool to help you write Git semantic commit messages by using AI.
8+
A simple tool to help you write Git semantic commit messages using AI.
99

1010
## References
1111

@@ -15,20 +15,19 @@ A simple tool to help you write Git semantic commit messages by using AI.
1515

1616
## Features
1717

18-
- Generates meaningful commit messages based on your code changes
19-
- It allows you to commit straight to the repository and integrate with the Git workflow.
20-
- The created message can be copied to the clipboard.
21-
- Easy-to-use command-line interface
22-
- By using the libgit2 library, there is no need to call an external command for security reasons
23-
- The system supports multiple AI models that are compatible with the OpenAI API
24-
- Auto sign-off commit messages, if specified environment is set to `true`
25-
- Socks5 and HTTP proxy supported
18+
- Generates meaningful, semantic commit messages from staged changes.
19+
- Commit directly to the repository with the `--commit` flag or copy the generated message with `--copy`.
20+
- Output formats: human-readable text, JSON (machine-readable) and table view. JSON output is useful for CI integrations and automation; table view makes it easy to scan multiple suggested lines.
21+
- Easy-to-use command-line interface with sensible defaults and confirm prompts (can be skipped with `--yes`).
22+
- Uses libgit2 via the `git2` crate, avoiding external git commands for improved security and performance.
23+
- Supports multiple OpenAI-compatible models and configurable API base, token, and proxy settings.
24+
- Optional auto sign-off of commits when `GIT_AUTO_SIGNOFF=true`.
25+
- Proxy support: HTTP and SOCKS5 (set via `OPENAI_API_PROXY`).
2626

27-
## How It Works
2827

29-
AIGitCommit looks at your Git staged changes and uses AI to make commit lines that are clear and helpful.
28+
## How It Works
3029

31-
It looks at the diff result and uses machine learning to figure out what your changes were meant to do and why you made them. It then generates a commit message that is clear and helpful.
30+
AIGitCommit inspects your staged Git changes, summarizes the intent of those changes, and generates clear semantic commit messages. It examines diffs and uses an AI model to infer intent and produce concise, useful commit lines.
3231

3332
## Install
3433

@@ -48,32 +47,33 @@ Those command will auto-download the latest version of the project and install i
4847

4948
## Configuration
5049

51-
Initially, you must configure your `OPENAI_*` environment variables to request prompts from an OpenAI-compatible API service. Set them as follows in your shell configuration file:
52-
53-
- `OPENAI_API_TOKEN`: Your individual OpenAI token
54-
- `OPENAI_API_BASE`: Your specified openAI request base
55-
- `OPENAI_MODEL_NAME`: Give the model name you wish to request
56-
- `OPENAI_API_PROXY`: The proxy address if you need to use a proxy
57-
- `GIT_AUTO_SIGNOFF`: If you want to sign off your commit messages, set this variable to `true`
50+
Configuration
5851

59-
If your network requirements a proxy to access the API service, you must specify the proxy address using the `OPENAI_API_PROXY` environment variable.
52+
Before using AIGitCommit, export the following environment variables (for example in your shell profile):
6053

61-
For instance, `http://127.0.0.1:1080` is suitable for an HTTP proxy, while `socks://127.0.0.1:1086` is an appropriate choice for a Socks5 proxy.
54+
- `OPENAI_API_TOKEN`: Your OpenAI-compatible API token.
55+
- `OPENAI_API_BASE`: The API base URL (useful for alternative providers or local proxies).
56+
- `OPENAI_MODEL_NAME`: The model name to query (e.g., a GPT-compatible model).
57+
- `OPENAI_API_PROXY`: Optional. Proxy address for network access (e.g., `http://127.0.0.1:1080` or `socks://127.0.0.1:1086`).
58+
- `GIT_AUTO_SIGNOFF`: Optional. Set to `true` to append a Signed-off-by line to commits.
6259

6360
## Usage
6461

65-
The way to use AIGitComment is really simple. For example, you can run `aigitcoment` in the current directory after staging the file to have git commits generated automatically before git commit. Additionally, you may provide the git directory using `aigitcommit <dir>`.
62+
Run `aigitcommit` in a repository with staged changes. Optionally provide a path to the git directory: `aigitcommit <dir>`.
6663

67-
1. You can use `--commit` parameters to commit the changes straight to the repository.
68-
2. Or you may just copy the commit message to the clipboard by using `--copy`.
64+
Common flags:
6965

70-
If you would like more usage settings, just use `aigitcommit --help` to get more details.
66+
1. `--commit` commit generated message directly to the repository.
67+
2. `--copy-to-clipboard` copy the generated message to the clipboard.
68+
3. `--json` print the suggestions as JSON for CI or automation.
69+
4. `--yes` skip confirmation prompts and apply the default action.
70+
5. `--signoff` append a Signed-off-by line to the commit message.
7171

72-
### Docker Image
72+
See `aigitcommit --help` for the full list of options.
7373

74-
You can also utilise the Docker image without installing the binary executable file.
74+
### Docker image
7575

76-
Simply enter the subsequent command or reference the `compose.yaml` file.
76+
AIGitCommit can run in Docker if you prefer not to install the binary locally. Example (read-only repository):
7777

7878
```bash
7979
docker run \
@@ -82,11 +82,11 @@ docker run \
8282
-e OPENAI_API_BASE='<api base>' \
8383
-e OPENAI_API_TOKEN='<api token>' \
8484
-e OPENAI_MODEL_NAME='<model name>' \
85-
-e OPENAI_API_PROXY='<the proxy address if you need>' \
85+
-e OPENAI_API_PROXY='<proxy if needed>' \
8686
ghcr.io/mingcheng/aigitcommit
8787
```
8888

89-
Notice: If you wish to utilise the `--commit` option, you must ensure that the `/repo` directory is writable:
89+
If you want to use `--commit` from inside the container, mount the repo as writable and run interactively:
9090

9191
```bash
9292
docker run \
@@ -96,41 +96,27 @@ docker run \
9696
-e OPENAI_API_BASE='<api base>' \
9797
-e OPENAI_API_TOKEN='<api token>' \
9898
-e OPENAI_MODEL_NAME='<model name>' \
99-
-e OPENAI_API_PROXY='<the proxy address if you need>' \
99+
-e OPENAI_API_PROXY='<proxy if needed>' \
100100
ghcr.io/mingcheng/aigitcommit --commit
101101
```
102102

103-
Tips: You can add `--yes` options to skip the confirm.
103+
Use `--yes` to skip interactive confirmations.
104104

105-
### Git Hook
105+
### Git hook
106106

107-
The `AIGitCommit` also supports git hooks. To integrate the hook, simply copy the `hooks/prepare-commit-msg` file into the repository's `.git/hooks/prepare-commit-msg`, and you're done.
107+
AIGitCommit ships a `hooks/prepare-commit-msg` hook you can copy into a repository's `.git/hooks/prepare-commit-msg` to automatically generate commit messages during `git commit`.
108108

109-
You can make it global by using Git's `core.hooksPath` instead of setting it up per repository.
109+
To install globally:
110110

111-
```
112-
# Create global hooks directory
111+
```bash
113112
mkdir -p ~/.git-hooks
114-
115-
# Copy the script contents above into this file
116-
vim ~/.git-hooks/prepare-commit-msg # Or use your preferred editor
117-
118-
# Make the script executable
113+
# copy the file from this project into ~/.git-hooks/prepare-commit-msg
119114
chmod +x ~/.git-hooks/prepare-commit-msg
120-
121-
# Configure Git to use global hooks
122115
git config --global core.hooksPath ~/.git-hooks
123116
```
124117

125-
Now every repository automatically gets `AIGitCommit` commit messages, just use `git commit` command.
126-
127-
128-
## Contributing
129-
130-
Contributions are welcome! Please feel free to submit a Pull Request.
118+
After installing the hook, `git commit` will run the hook and populate the commit message. Use `--no-verify` to bypass hooks when necessary.
131119

132120
## License
133121

134-
This project is licensed under the MIT License - see the LICENSE file for details.
135-
136-
`- eof -`
122+
This project is licensed under the MIT License. See the `LICENSE` file for details.

assets/screenshots.png

500 KB
Loading

0 commit comments

Comments
 (0)