opencommit 2.2.10 β 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -44
- package/out/cli.cjs +480 -454
- package/out/github-action.cjs +20 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
<img src=".github/logo-grad.svg" alt="OpenCommit logo"/>
|
|
4
4
|
<h1 align="center">OpenCommit</h1>
|
|
5
5
|
<h4 align="center">Follow the bird <a href="https://twitter.com/io_Y_oi"><img src="https://img.shields.io/twitter/follow/io_Y_oi?style=flat&label=io_Y_oi&logo=twitter&color=0bf&logoColor=fff" align="center"></a>
|
|
6
|
-
</h4>
|
|
7
6
|
</div>
|
|
8
7
|
<h2>Auto-generate meaningful commits in 1 second</h2>
|
|
9
8
|
<p>Killing lame commits with AI π€―π«</p>
|
|
10
9
|
<a href="https://www.npmjs.com/package/opencommit"><img src="https://img.shields.io/npm/v/opencommit" alt="Current version"></a>
|
|
10
|
+
<h4 align="center">πͺ© Winner of GitHub 2023 HACKATHON <a href="https://twitter.com/io_Y_oi"><img style="width:18px; height:18px;" src=".github/github-mark-white.png" align="center"></a>
|
|
11
|
+
</h4>
|
|
11
12
|
</div>
|
|
12
13
|
|
|
13
14
|
---
|
|
@@ -16,15 +17,35 @@
|
|
|
16
17
|
<img src=".github/opencommit-example.png" alt="OpenCommit example"/>
|
|
17
18
|
</div>
|
|
18
19
|
|
|
19
|
-
All the commits in this repo are
|
|
20
|
+
All the commits in this repo are authored by OpenCommit β look at [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emojis and long commit descriptions are configurable.
|
|
20
21
|
|
|
21
|
-
## Setup OpenCommit as a
|
|
22
|
+
## Setup OpenCommit as a CLI tool
|
|
23
|
+
|
|
24
|
+
You can use OpenCommit by simply running it via the CLI like this `oco`. 2 seconds and your staged changes are committed with a meaningful message.
|
|
25
|
+
|
|
26
|
+
1. Install OpenCommit globally to use in any repository:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm install -g opencommit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure that you add your payment details, so the API works.
|
|
33
|
+
|
|
34
|
+
3. Set the key to OpenCommit config:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
opencommit config set OCO_OPENAI_API_KEY=<your_api_key>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Your API key is stored locally in the `~/.opencommit` config file.
|
|
41
|
+
|
|
42
|
+
## Setup OpenCommit as a GitHub Action π₯
|
|
22
43
|
|
|
23
44
|
OpenCommit is now available as a GitHub Action which automatically improves all new commits messages when you push to remote!
|
|
24
45
|
|
|
25
|
-
This is great if you want to make sure all of the commits in all of repository branches are meaningful and not lame like `fix1` or `done2`.
|
|
46
|
+
This is great if you want to make sure all of the commits in all of your repository branches are meaningful and not lame like `fix1` or `done2`.
|
|
26
47
|
|
|
27
|
-
Create a file `.github/workflows/opencommit.yml` with contents below:
|
|
48
|
+
Create a file `.github/workflows/opencommit.yml` with the contents below:
|
|
28
49
|
|
|
29
50
|
```yml
|
|
30
51
|
name: 'OpenCommit Action'
|
|
@@ -68,31 +89,11 @@ jobs:
|
|
|
68
89
|
OCO_LANGUAGE: en
|
|
69
90
|
```
|
|
70
91
|
|
|
71
|
-
That is it. Now when you push to any branch in your repo β all NEW commits are being improved by never-tired
|
|
92
|
+
That is it. Now when you push to any branch in your repo β all NEW commits are being improved by your never-tired AI.
|
|
72
93
|
|
|
73
|
-
Make sure you exclude public collaboration branches (`main`, `dev`, `etc`) in `branches-ignore`, so OpenCommit does not rebase commits there
|
|
94
|
+
Make sure you exclude public collaboration branches (`main`, `dev`, `etc`) in `branches-ignore`, so OpenCommit does not rebase commits there while improving the messages.
|
|
74
95
|
|
|
75
|
-
Interactive rebase (`rebase -i`) changes
|
|
76
|
-
|
|
77
|
-
## Setup OpenCommit as a CLI
|
|
78
|
-
|
|
79
|
-
You can use OpenCommit by simply running it via CLI like this `oco`. 2 seconds and your staged changes are committed with a meaningful message.
|
|
80
|
-
|
|
81
|
-
1. Install OpenCommit globally to use in any repository:
|
|
82
|
-
|
|
83
|
-
```sh
|
|
84
|
-
npm install -g opencommit
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure you add payment details, so API works.
|
|
88
|
-
|
|
89
|
-
3. Set the key to OpenCommit config:
|
|
90
|
-
|
|
91
|
-
```sh
|
|
92
|
-
opencommit config set OCO_OPENAI_API_KEY=<your_api_key>
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Your api key is stored locally in `~/.opencommit` config file.
|
|
96
|
+
Interactive rebase (`rebase -i`) changes commits' SHA, so the commit history in remote becomes different from your local branch history. This is okay if you work on the branch alone, but may be inconvenient for other collaborators.
|
|
96
97
|
|
|
97
98
|
## Usage
|
|
98
99
|
|
|
@@ -107,30 +108,31 @@ You can also use the `oco` shortcut:
|
|
|
107
108
|
|
|
108
109
|
```sh
|
|
109
110
|
git add <files...>
|
|
110
|
-
|
|
111
|
+
oco
|
|
111
112
|
```
|
|
112
113
|
|
|
113
114
|
## Configuration
|
|
114
115
|
|
|
115
116
|
### Local per repo configuration
|
|
116
117
|
|
|
117
|
-
Create
|
|
118
|
+
Create a `.env` file and add OpenCommit config variables there like this:
|
|
118
119
|
|
|
119
120
|
```env
|
|
120
|
-
OCO_OPENAI_API_KEY=<your
|
|
121
|
-
OCO_OPENAI_MAX_TOKENS=<max response tokens from
|
|
122
|
-
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to
|
|
121
|
+
OCO_OPENAI_API_KEY=<your OpenAI API token>
|
|
122
|
+
OCO_OPENAI_MAX_TOKENS=<max response tokens from OpenAI API>
|
|
123
|
+
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to OpenAI api>
|
|
123
124
|
OCO_DESCRIPTION=<postface a message with ~3 sentences description>
|
|
124
125
|
OCO_EMOJI=<add GitMoji>
|
|
125
126
|
OCO_MODEL=<either gpt-3.5-turbo or gpt-4>
|
|
126
127
|
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
|
|
128
|
+
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=<message template placeholder, example: '$msg'>
|
|
127
129
|
```
|
|
128
130
|
|
|
129
131
|
### Global config for all repos
|
|
130
132
|
|
|
131
|
-
Local config still has more priority
|
|
133
|
+
Local config still has more priority than Global config, but you may set `OCO_MODEL` and `OCO_LOCALE` globally and set local configs for `OCO_EMOJI` and `OCO_DESCRIPTION` per repo which is more convenient.
|
|
132
134
|
|
|
133
|
-
Simply
|
|
135
|
+
Simply set any of the variables above like this:
|
|
134
136
|
|
|
135
137
|
```sh
|
|
136
138
|
oco config set OCO_OPENAI_API_KEY=gpt-4
|
|
@@ -142,15 +144,15 @@ Configure [GitMoji](https://gitmoji.dev/) to preface a message.
|
|
|
142
144
|
oco config set OCO_EMOJI=true
|
|
143
145
|
```
|
|
144
146
|
|
|
145
|
-
To remove preface
|
|
147
|
+
To remove preface emojis:
|
|
146
148
|
|
|
147
149
|
```sh
|
|
148
150
|
oco config set OCO_EMOJI=false
|
|
149
151
|
```
|
|
150
152
|
|
|
151
|
-
### Switch to GPT-4
|
|
153
|
+
### Switch to GPT-4 or other models
|
|
152
154
|
|
|
153
|
-
By default OpenCommit uses
|
|
155
|
+
By default, OpenCommit uses `gpt-3.5-turbo-16k` model.
|
|
154
156
|
|
|
155
157
|
You may switch to GPT-4 which performs better, but costs ~x15 times more π€
|
|
156
158
|
|
|
@@ -158,7 +160,13 @@ You may switch to GPT-4 which performs better, but costs ~x15 times more π€
|
|
|
158
160
|
oco config set OCO_MODEL=gpt-4
|
|
159
161
|
```
|
|
160
162
|
|
|
161
|
-
|
|
163
|
+
or for as a cheaper option:
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
oco config set OCO_MODEL=gpt-3.5-turbo
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Make sure that you spell it `gpt-4` (lowercase) and that you have API access to the 4th model. Even if you have ChatGPT+, that doesn't necessarily mean that you have API access to GPT-4.
|
|
162
170
|
|
|
163
171
|
## Locale configuration
|
|
164
172
|
|
|
@@ -176,7 +184,7 @@ oco config set OCO_LANGUAGE=French
|
|
|
176
184
|
oco config set OCO_LANGUAGE=franΓ§aise
|
|
177
185
|
```
|
|
178
186
|
|
|
179
|
-
The default language
|
|
187
|
+
The default language setting is **English**
|
|
180
188
|
All available languages are currently listed in the [i18n](https://github.com/di-sukharev/opencommit/tree/master/src/i18n) folder
|
|
181
189
|
|
|
182
190
|
### Git flags
|
|
@@ -193,22 +201,30 @@ is translated to :
|
|
|
193
201
|
git commit -m "${generatedMessage}" --no-verify
|
|
194
202
|
```
|
|
195
203
|
|
|
204
|
+
To include a message in the generated message, you can utilize the template function! For instance:
|
|
205
|
+
|
|
206
|
+
```sh
|
|
207
|
+
oco '$msg #205β
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
> opencommit examines placeholders in the parameters, allowing you to append additional information before and after the placeholders, such as the relevant Issue or Pull Request. Similarly, you have the option to customize the OCO_MESSAGE_TEMPLATE_PLACEHOLDER configuration item, for example, simplifying it to $m!"
|
|
211
|
+
|
|
196
212
|
### Ignore files
|
|
197
213
|
|
|
198
|
-
You can
|
|
214
|
+
You can remove files from being sent to OpenAI by creating a `.opencommitignore` file. For example:
|
|
199
215
|
|
|
200
216
|
```ignorelang
|
|
201
217
|
path/to/large-asset.zip
|
|
202
218
|
**/*.jpg
|
|
203
219
|
```
|
|
204
220
|
|
|
205
|
-
This
|
|
221
|
+
This helps prevent opencommit from uploading artifacts and large files.
|
|
206
222
|
|
|
207
223
|
By default, opencommit ignores files matching: `*-lock.*` and `*.lock`
|
|
208
224
|
|
|
209
225
|
## Git hook (KILLER FEATURE)
|
|
210
226
|
|
|
211
|
-
You can set OpenCommit as Git [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. Hook integrates with
|
|
227
|
+
You can set OpenCommit as Git [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. Hook integrates with your IDE Source Control and allows you to edit the message before committing.
|
|
212
228
|
|
|
213
229
|
To set the hook:
|
|
214
230
|
|
|
@@ -233,4 +249,4 @@ Or follow the process of your IDE Source Control feature, when it calls `git com
|
|
|
233
249
|
|
|
234
250
|
## Payments
|
|
235
251
|
|
|
236
|
-
You pay for your
|
|
252
|
+
You pay for your requests to OpenAI API. OpenCommit uses ChatGPT (3.5-turbo) official model, which is ~15x times cheaper than GPT-4.
|