Skip to content

Commit 45dee11

Browse files
authoredMar 18, 2025··
Merge pull request #7 from mingcheng/develop
improved some CI configuration and fixed a few minor bugs.
2 parents 340000c + 4bc6a50 commit 45dee11

File tree

8 files changed

+108
-28
lines changed

8 files changed

+108
-28
lines changed
 

‎.github/workflows/ghcr.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
build-and-push-image:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
attestations: write
22+
id-token: write
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
- name: Log in to the Container registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
- uses: benjlevesque/short-sha@v3.0
38+
id: short-sha
39+
with:
40+
length: 7
41+
- name: Build and push Docker image
42+
id: push
43+
uses: docker/build-push-action@v6
44+
with:
45+
context: .
46+
push: ${{ github.event_name != 'pull_request' }}
47+
tags: |
48+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
49+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.short-sha.outputs.sha }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
- name: Generate artifact attestation
52+
uses: actions/attest-build-provenance@v2
53+
with:
54+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
55+
subject-digest: ${{ steps.push.outputs.digest }}
56+
push-to-registry: true

‎.github/workflows/rust.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ jobs:
3434
steps:
3535
- uses: actions/checkout@v4
3636
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
37-
- run: rustup component add clippy && cargo clippy -- -D warnings
38-
- run: rustup component add rustfmt && cargo fmt --all -- --check
37+
- run: rustup component add clippy --toolchain ${{ matrix.toolchain }}
38+
- run: rustup component add rustfmt --toolchain ${{ matrix.toolchain }}
39+
- run: cargo clippy -- -D warnings
40+
- run: cargo fmt --all -- --check
3941
- run: cargo build --verbose
4042
- run: cargo test --verbose

‎Cargo.lock

+24-18
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
1919

2020
[[package]]
2121
name = "aigitcommit"
22-
version = "1.3.1"
22+
version = "1.3.2"
2323
dependencies = [
2424
"arboard",
2525
"askama",
@@ -771,14 +771,14 @@ dependencies = [
771771

772772
[[package]]
773773
name = "getrandom"
774-
version = "0.3.1"
774+
version = "0.3.2"
775775
source = "registry+https://github.com/rust-lang/crates.io-index"
776-
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
776+
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
777777
dependencies = [
778778
"cfg-if",
779779
"libc",
780-
"wasi 0.13.3+wasi-0.2.2",
781-
"windows-targets 0.52.6",
780+
"r-efi",
781+
"wasi 0.14.2+wasi-0.2.4",
782782
]
783783

784784
[[package]]
@@ -789,9 +789,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
789789

790790
[[package]]
791791
name = "git2"
792-
version = "0.20.0"
792+
version = "0.20.1"
793793
source = "registry+https://github.com/rust-lang/crates.io-index"
794-
checksum = "3fda788993cc341f69012feba8bf45c0ba4f3291fcc08e214b4d5a7332d88aff"
794+
checksum = "5220b8ba44c68a9a7f7a7659e864dd73692e417ef0211bea133c7b74e031eeb9"
795795
dependencies = [
796796
"bitflags 2.9.0",
797797
"libc",
@@ -1189,9 +1189,9 @@ checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
11891189

11901190
[[package]]
11911191
name = "libgit2-sys"
1192-
version = "0.18.0+1.9.0"
1192+
version = "0.18.1+1.9.0"
11931193
source = "registry+https://github.com/rust-lang/crates.io-index"
1194-
checksum = "e1a117465e7e1597e8febea8bb0c410f1c7fb93b1e1cddf34363f8390367ffec"
1194+
checksum = "e1dcb20f84ffcdd825c7a311ae347cce604a6f084a767dec4a4929829645290e"
11951195
dependencies = [
11961196
"cc",
11971197
"libc",
@@ -1675,6 +1675,12 @@ dependencies = [
16751675
"proc-macro2",
16761676
]
16771677

1678+
[[package]]
1679+
name = "r-efi"
1680+
version = "5.2.0"
1681+
source = "registry+https://github.com/rust-lang/crates.io-index"
1682+
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
1683+
16781684
[[package]]
16791685
name = "rand"
16801686
version = "0.8.5"
@@ -1838,9 +1844,9 @@ dependencies = [
18381844

18391845
[[package]]
18401846
name = "rustls"
1841-
version = "0.23.23"
1847+
version = "0.23.25"
18421848
source = "registry+https://github.com/rust-lang/crates.io-index"
1843-
checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395"
1849+
checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c"
18441850
dependencies = [
18451851
"once_cell",
18461852
"ring",
@@ -1882,9 +1888,9 @@ dependencies = [
18821888

18831889
[[package]]
18841890
name = "rustls-webpki"
1885-
version = "0.102.8"
1891+
version = "0.103.0"
18861892
source = "registry+https://github.com/rust-lang/crates.io-index"
1887-
checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9"
1893+
checksum = "0aa4eeac2588ffff23e9d7a7e9b3f971c5fb5b7ebc9452745e0c232c64f83b2f"
18881894
dependencies = [
18891895
"ring",
18901896
"rustls-pki-types",
@@ -2165,7 +2171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
21652171
checksum = "488960f40a3fd53d72c2a29a58722561dee8afdd175bd88e3db4677d7b2ba600"
21662172
dependencies = [
21672173
"fastrand",
2168-
"getrandom 0.3.1",
2174+
"getrandom 0.3.2",
21692175
"once_cell",
21702176
"rustix 1.0.2",
21712177
"windows-sys 0.59.0",
@@ -2514,9 +2520,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
25142520

25152521
[[package]]
25162522
name = "wasi"
2517-
version = "0.13.3+wasi-0.2.2"
2523+
version = "0.14.2+wasi-0.2.4"
25182524
source = "registry+https://github.com/rust-lang/crates.io-index"
2519-
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
2525+
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
25202526
dependencies = [
25212527
"wit-bindgen-rt",
25222528
]
@@ -2902,9 +2908,9 @@ checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486"
29022908

29032909
[[package]]
29042910
name = "wit-bindgen-rt"
2905-
version = "0.33.0"
2911+
version = "0.39.0"
29062912
source = "registry+https://github.com/rust-lang/crates.io-index"
2907-
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
2913+
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
29082914
dependencies = [
29092915
"bitflags 2.9.0",
29102916
]

‎Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "aigitcommit"
3-
version = "1.3.1"
4-
edition = "2024"
3+
version = "1.3.2"
4+
edition = "2021"
55
description = "A simple git commit message generator by OpenAI compaction model."
66
license-file = "LICENSE"
77
readme = "README.md"

‎README.md

+16
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ The way to use AIGitComment is really simple. For example, you can run `aigitcom
5959

6060
If you would like more usage settings, just use `aigitcommit --help` to get more details.
6161

62+
### Docker Image
63+
64+
You can also utilise the Docker image without installing the binary executable file.
65+
66+
Simply enter the subsequent command or reference the `compose.yaml` file.
67+
68+
```bash
69+
docker run --rm ghcr.io/mingcheng/aigitcommit:latest \
70+
-v .:\repo:ro \
71+
-e OPENAI_API_BASE='<openai api base>' \
72+
-e OPENAI_API_TOKEN='<token>' \
73+
-e OPENAI_MODEL_NAME='<model name>'
74+
```
75+
76+
Notice: If you wish to utilise the `--commit` option, you must ensure that the `/repo` directory is writable.
77+
6278
### Git Hook
6379

6480
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.

‎compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
OPENAI_API_BASE: ""
88
OPENAI_API_TOKEN: ""
99
OPENAI_MODEL_NAME: ""
10-
OPENAI_APT_PROXY: ""
10+
OPENAI_API_PROXY: ""
1111

1212
volumes:
1313
- .:/repo:ro

‎src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* File Created: 2025-03-01 17:17:30
1010
*
1111
* Modified By: mingcheng (mingcheng@apache.org)
12-
* Last Modified: 2025-03-17 18:29:42
12+
* Last Modified: 2025-03-18 12:22:56
1313
*/
1414

1515
use aigitcommit::cli::Cli;
@@ -27,7 +27,7 @@ use std::error::Error;
2727
use std::fs::File;
2828
use std::io::Write;
2929
use std::{env, fs};
30-
use tracing::{Level, debug, trace};
30+
use tracing::{debug, trace, Level};
3131

3232
#[tokio::main]
3333
async fn main() -> std::result::Result<(), Box<dyn Error>> {

‎src/openai.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
* File Created: 2025-03-01 21:55:58
1010
*
1111
* Modified By: mingcheng (mingcheng@apache.org)
12-
* Last Modified: 2025-03-06 17:59:08
12+
* Last Modified: 2025-03-17 22:53:48
1313
*/
1414
use askama::Template;
1515
use async_openai::config::OPENAI_API_BASE;
1616
use async_openai::error::OpenAIError;
1717
use async_openai::{
18-
Client,
1918
config::OpenAIConfig,
2019
types::{ChatCompletionRequestMessage, CreateChatCompletionRequestArgs},
20+
Client,
2121
};
2222
use log::trace;
2323
use reqwest::header::{HeaderMap, HeaderValue};
@@ -66,7 +66,7 @@ impl OpenAI {
6666
});
6767

6868
// Set up proxy if specified
69-
let proxy_addr: String = env::var("OPENAI_APT_PROXY").unwrap_or_else(|_| String::from(""));
69+
let proxy_addr: String = env::var("OPENAI_API_PROXY").unwrap_or_else(|_| String::from(""));
7070
if !proxy_addr.is_empty() {
7171
trace!("Using proxy: {}", proxy_addr);
7272
http_client_builder = http_client_builder.proxy(Proxy::all(proxy_addr).unwrap());

0 commit comments

Comments
 (0)
Please sign in to comment.