You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That is it. Now when you push to any branch in your repo — all NEW commits are being improved by your never-tired AI.
93
-
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.
95
-
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.
97
-
98
42
## Usage
99
43
100
44
You can call OpenCommit directly to generate a commit message for your staged changes:
@@ -121,11 +65,12 @@ Create a `.env` file and add OpenCommit config variables there like this:
121
65
OCO_OPENAI_API_KEY=<your OpenAI API token>
122
66
OCO_OPENAI_MAX_TOKENS=<max response tokens from OpenAI API>
123
67
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to OpenAI api>
124
-
OCO_DESCRIPTION=<postface a message with ~3 sentences description>
125
-
OCO_EMOJI=<add GitMoji>
126
-
OCO_MODEL=<either gpt-3.5-turboor gpt-4>
68
+
OCO_DESCRIPTION=<postface a message with ~3 sentences description of the changes>
69
+
OCO_EMOJI=<boolean, add GitMoji>
70
+
OCO_MODEL=<either 'gpt-4', 'gpt-3.5-turbo-16k' (default), 'gpt-3.5-turbo-0613' or 'gpt-3.5-turbo'>
127
71
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
OCO_PROMPT_MODULE=<either conventional-commit or @commitlint, default: conventional-commit>
129
74
```
130
75
131
76
### Global config for all repos
@@ -168,7 +113,7 @@ oco config set OCO_MODEL=gpt-3.5-turbo
168
113
169
114
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.
170
115
171
-
## Locale configuration
116
+
###Locale configuration
172
117
173
118
To globally specify the language used to generate commit messages:
174
119
@@ -187,7 +132,55 @@ oco config set OCO_LANGUAGE=française
187
132
The default language setting is **English**
188
133
All available languages are currently listed in the [i18n](https://github.com/di-sukharev/opencommit/tree/master/src/i18n) folder
189
134
190
-
### Git flags
135
+
### Switch to `@commitlint`
136
+
137
+
OpenCommit allows you to choose the prompt module used to generate commit messages. By default, OpenCommit uses its conventional-commit message generator. However, you can switch to using the `@commitlint` prompt module if you prefer. This option lets you generate commit messages in respect with the local config.
138
+
139
+
You can set this option by running the following command:
140
+
141
+
```sh
142
+
oco config set OCO_PROMPT_MODULE=<module>
143
+
```
144
+
145
+
Replace `<module>` with either `conventional-commit` or `@commitlint`.
146
+
147
+
#### Example:
148
+
149
+
To switch to using th` '@commitlint` prompt module, run:
150
+
151
+
```sh
152
+
oco config set OCO_PROMPT_MODULE=@commitlint
153
+
```
154
+
155
+
To switch back to the default conventional-commit message generator, run:
156
+
157
+
```sh
158
+
oco config set OCO_PROMPT_MODULE=conventional-commit
159
+
```
160
+
161
+
#### Integrating with `@commitlint`
162
+
163
+
The integration between `@commitlint` and OpenCommit is done automatically the first time OpenCommit is run with `OCO_PROMPT_MODULE` set to `@commitlint`. However, if you need to force set or reset the configuration for `@commitlint`, you can run the following command:
164
+
165
+
```sh
166
+
oco commitlint force
167
+
```
168
+
169
+
To view the generated configuration for `@commitlint`, you can use this command:
170
+
171
+
```sh
172
+
oco commitlint get
173
+
```
174
+
175
+
This allows you to ensure that the configuration is set up as desired.
176
+
177
+
Additionally, the integration creates a file named `.opencommit-commitlint` which contains the prompts used for the local `@commitlint` configuration. You can modify this file to fine-tune the example commit message generated by OpenAI. This gives you the flexibility to make adjustments based on your preferences or project guidelines.
178
+
179
+
OpenCommit generates a file named `.opencommit-commitlint` in your project directory which contains the prompts used for the local `@commitlint` configuration. You can modify this file to fine-tune the example commit message generated by OpenAI. If the local `@commitlint` configuration changes, this file will be updated the next time OpenCommit is run.
180
+
181
+
This offers you greater control over the generated commit messages, allowing for customization that aligns with your project's conventions.
182
+
183
+
## Git flags
191
184
192
185
The `opencommit` or `oco` commands can be used in place of the `git commit -m "${generatedMessage}"` command. This means that any regular flags that are used with the `git commit` command will also be applied when using `opencommit` or `oco`.
193
186
@@ -201,14 +194,41 @@ is translated to :
201
194
git commit -m "${generatedMessage}" --no-verify
202
195
```
203
196
204
-
To include a message in the generated message, you can utilize the template function! For instance:
197
+
To include a message in the generated message, you can utilize the template function, for instance:
205
198
206
199
```sh
207
-
oco '$msg #205’
200
+
oco '#205: $msg’
208
201
```
209
202
210
203
> 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
204
205
+
### Message Template Placeholder Config
206
+
207
+
#### Overview
208
+
209
+
The `OCO_MESSAGE_TEMPLATE_PLACEHOLDER` feature in the `opencommit` tool allows users to embed a custom message within the generated commit message using a template function. This configuration is designed to enhance the flexibility and customizability of commit messages, making it easier for users to include relevant information directly within their commits.
210
+
211
+
#### Implementation Details
212
+
213
+
In our codebase, the implementation of this feature can be found in the following segment:
214
+
215
+
```javascript
216
+
commitMessage = messageTemplate.replace(
217
+
config?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
218
+
commitMessage
219
+
);
220
+
```
221
+
222
+
This line is responsible for replacing the placeholder in the `messageTemplate` with the actual `commitMessage`.
223
+
224
+
#### Usage
225
+
226
+
For instance, using the command `oco '$msg#205’`, users can leverage this feature. The provided code represents the backend mechanics of such commands, ensuring that the placeholder is replaced with the appropriate commit message.
227
+
228
+
#### Committing with the Message
229
+
230
+
Once users have generated their desired commit message, they can proceed to commit using the generated message. By understanding the feature's full potential and its implementation details, users can confidently use the generated messages for their commits.
231
+
212
232
### Ignore files
213
233
214
234
You can remove files from being sent to OpenAI by creating a `.opencommitignore` file. For example:
@@ -247,6 +267,67 @@ git commit
247
267
248
268
Or follow the process of your IDE Source Control feature, when it calls `git commit` command — OpenCommit will integrate into the flow.
249
269
270
+
## Setup OpenCommit as a GitHub Action (BETA) 🔥
271
+
272
+
OpenCommit is now available as a GitHub Action which automatically improves all new commits messages when you push to remote!
273
+
274
+
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`.
275
+
276
+
Create a file `.github/workflows/opencommit.yml` with the contents below:
277
+
278
+
```yml
279
+
name: 'OpenCommit Action'
280
+
281
+
on:
282
+
push:
283
+
# this list of branches is often enough,
284
+
# but you may still ignore other public branches
285
+
branches-ignore: [main master dev development release]
That is it. Now when you push to any branch in your repo — all NEW commits are being improved by your never-tired AI.
322
+
323
+
Make sure you exclude public collaboration branches (`main`, `dev`, `etc`) in `branches-ignore`, so OpenCommit does not rebase commits there while improving the messages.
324
+
325
+
Interactive rebase (`rebase -i`) changes commits' SHA, so the commit historyin 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.
326
+
250
327
## Payments
251
328
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.
329
+
You pay for your requests to OpenAI API on your own.
330
+
331
+
OpenCommit stores your key locally.
332
+
333
+
OpenCommit by default uses ChatGPT (3.5-turbo-16k) official model, which is a lot cheaper than gpt-4.
0 commit comments