Skip to content

Commit 12956d7

Browse files
authored
feat: Integrate @commitlint for Enhanced Commit Message Generation and Configuration Support (#209)
* add commitlint support * refactor code * improve readme text
1 parent c1627bb commit 12956d7

29 files changed

Lines changed: 13776 additions & 12170 deletions

README.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
OCO_EMOJI: false
8888
OCO_MODEL: gpt-3.5-turbo
8989
OCO_LANGUAGE: en
90+
OCO_PROMPT_MODULE: conventional-commit
9091
```
9192
9293
That is it. Now when you push to any branch in your repo — all NEW commits are being improved by your never-tired AI.
@@ -126,6 +127,7 @@ OCO_EMOJI=<add GitMoji>
126127
OCO_MODEL=<either gpt-3.5-turbo or gpt-4>
127128
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
128129
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=<message template placeholder, example: '$msg'>
130+
OCO_PROMPT_MODULE=<either conventional-commit or @commitlint>
129131
```
130132

131133
### Global config for all repos
@@ -168,7 +170,7 @@ oco config set OCO_MODEL=gpt-3.5-turbo
168170

169171
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.
170172

171-
## Locale configuration
173+
### Locale configuration
172174

173175
To globally specify the language used to generate commit messages:
174176

@@ -187,7 +189,55 @@ oco config set OCO_LANGUAGE=française
187189
The default language setting is **English**
188190
All available languages are currently listed in the [i18n](https://github.com/di-sukharev/opencommit/tree/master/src/i18n) folder
189191

190-
### Git flags
192+
### Switch to `@commitlint`
193+
194+
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.
195+
196+
You can set this option by running the following command:
197+
198+
```sh
199+
oco config set OCO_PROMPT_MODULE=<module>
200+
```
201+
202+
Replace `<module>` with either `conventional-commit` or `@commitlint`.
203+
204+
#### Example:
205+
206+
To switch to using th` '@commitlint` prompt module, run:
207+
208+
```sh
209+
oco config set OCO_PROMPT_MODULE=@commitlint
210+
```
211+
212+
To switch back to the default conventional-commit message generator, run:
213+
214+
```sh
215+
oco config set OCO_PROMPT_MODULE=conventional-commit
216+
```
217+
218+
#### Integrating with `@commitlint`
219+
220+
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:
221+
222+
```sh
223+
oco commitlint force
224+
```
225+
226+
To view the generated configuration for `@commitlint`, you can use this command:
227+
228+
```sh
229+
oco commitlint get
230+
```
231+
232+
This allows you to ensure that the configuration is set up as desired.
233+
234+
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+
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.
237+
238+
This offers you greater control over the generated commit messages, allowing for customization that aligns with your project's conventions.
239+
240+
## Git flags
191241

192242
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`.
193243

0 commit comments

Comments
 (0)