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
* chore(README.md): update setup instructions for OpenCommit as a GitHub Action
fix(commit.ts): check if OCO_MESSAGE_TEMPLATE_PLACEHOLDER exists before replacing it in the commit message template
The README.md file has been updated to reflect the changes in the setup instructions for using OpenCommit as a GitHub Action. The new instructions provide a file template for the GitHub Action workflow and include the latest version of the OpenCommit GitHub Action.
In the commit.ts file, a fix has been made to check if the OCO_MESSAGE_TEMPLATE_PLACEHOLDER exists before replacing it in the commit message template. This ensures that the replacement is only performed when the placeholder is present, preventing any potential errors.
That is it. Now when you push to any branch in your repo — all NEW commits are being improved by your never-tired AI.
94
-
95
-
Make sure you exclude public collaboration branches (`main`, `dev`, `etc`) in `branches-ignore`, so OpenCommit does not rebase commits there while improving the messages.
96
-
97
-
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.
98
-
99
42
## Usage
100
43
101
44
You can call OpenCommit directly to generate a commit message for your staged changes:
@@ -122,12 +65,12 @@ Create a `.env` file and add OpenCommit config variables there like this:
122
65
OCO_OPENAI_API_KEY=<your OpenAI API token>
123
66
OCO_OPENAI_MAX_TOKENS=<max response tokens from OpenAI API>
124
67
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to OpenAI api>
125
-
OCO_DESCRIPTION=<postface a message with ~3 sentences description>
126
-
OCO_EMOJI=<add GitMoji>
127
-
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'>
128
71
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
OCO_PROMPT_MODULE=<either conventional-commit or @commitlint, default: conventional-commit>
131
74
```
132
75
133
76
### Global config for all repos
@@ -233,7 +176,7 @@ This allows you to ensure that the configuration is set up as desired.
233
176
234
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.
235
178
236
-
Additionally, 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.
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.
237
180
238
181
This offers you greater control over the generated commit messages, allowing for customization that aligns with your project's conventions.
239
182
@@ -251,10 +194,10 @@ is translated to :
251
194
git commit -m "${generatedMessage}" --no-verify
252
195
```
253
196
254
-
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:
255
198
256
199
```sh
257
-
oco '$msg #205’
200
+
oco '#205: $msg’
258
201
```
259
202
260
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!"
@@ -268,12 +211,14 @@ The `OCO_MESSAGE_TEMPLATE_PLACEHOLDER` feature in the `opencommit` tool allows u
268
211
#### Implementation Details
269
212
270
213
In our codebase, the implementation of this feature can be found in the following segment:
214
+
271
215
```javascript
272
216
commitMessage = messageTemplate.replace(
273
-
config?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
274
-
commitMessage
217
+
config?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
218
+
commitMessage
275
219
);
276
220
```
221
+
277
222
This line is responsible for replacing the placeholder in the `messageTemplate` with the actual `commitMessage`.
278
223
279
224
#### Usage
@@ -322,6 +267,63 @@ git commit
322
267
323
268
Or follow the process of your IDE Source Control feature, when it calls `git commit` command — OpenCommit will integrate into the flow.
324
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
+
325
327
## Payments
326
328
327
329
You pay for your requests to OpenAI API. OpenCommit uses ChatGPT (3.5-turbo) official model, which is ~15x times cheaper than GPT-4.
0 commit comments