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
Permission is hereby granted, free of charge, to any person obtaining a
6
6
copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
All the commits in this repo are done with OpenCommit — look into [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emoji and long commit description text is configurable.
20
20
21
-
## Setup
21
+
## Setup OpenCommit as a Github Action 🔥
22
+
23
+
OpenCommit is now available as a GitHub Action which automatically improves all new commits messages when you push to remote!
24
+
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`.
26
+
27
+
Create a file `.github/workflows/opencommit.yml` with contents below:
28
+
29
+
```yml
30
+
name: 'OpenCommit Action'
31
+
32
+
on:
33
+
push:
34
+
# this list of branches is often enough,
35
+
# but you may still ignore other public branches
36
+
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 never-tired-AI.
72
+
73
+
Make sure you exclude public collaboration branches (`main`, `dev`, `etc`) in `branches-ignore`, so OpenCommit does not rebase commits there when improving the messages.
74
+
75
+
Interactive rebase (`rebase -i`) changes commit SHA, so commit history in remote becomes different with your local branch history. It's ok when you work on the branch alone, but may be inconvenient for other collaborators.
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.
22
80
23
81
1. Install OpenCommit globally to use in any repository:
24
82
@@ -31,7 +89,7 @@ All the commits in this repo are done with OpenCommit — look into [the commits
opencommit config set OCO_OPENAI_API_KEY=<your_api_key>
35
93
```
36
94
37
95
Your api key is stored locally in `~/.opencommit` config file.
@@ -45,88 +103,108 @@ git add <files...>
45
103
opencommit
46
104
```
47
105
48
-
You can also use the `oc` shortcut:
106
+
You can also use the `oco` shortcut:
49
107
50
108
```sh
51
109
git add <files...>
52
110
oc
53
111
```
54
112
55
-
## Features
113
+
## Configuration
56
114
57
-
### Switch to Azure OpenAI
58
-
59
-
By default OpenCommit uses [OpenAI](https://openai.com).
115
+
### Local per repo configuration
60
116
61
-
You could switch to [Azure OpenAI Service](https://learn.microsoft.com/azure/cognitive-services/openai/)🚀
117
+
Create an `.env` file and add OpenCommit config variables there like this:
62
118
63
-
```sh
64
-
opencommit config set OPENAI_API_TYPE=azure
119
+
```env
120
+
OCO_OPENAI_API_KEY=<your openAI API token>
121
+
OCO_OPENAI_MAX_TOKENS=<max response tokens from openAI API>
122
+
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to openAI api>
123
+
OCO_DESCRIPTION=<postface a message with ~3 sentences description>
124
+
OCO_EMOJI=<add GitMoji>
125
+
OCO_MODEL=<either gpt-3.5-turbo or gpt-4>
126
+
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
65
127
```
66
128
67
-
Of course need to set 'OPENAI_API_KEY'. And also need to set the
68
-
'OPENAI_BASE_PATH' for the endpoint and set the deployment name to
69
-
'model'.
129
+
### Global config for all repos
70
130
71
-
### Switch to GPT-4
72
-
73
-
By default OpenCommit uses GPT-3.5-turbo (ChatGPT).
131
+
Local config still has more priority as 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.
74
132
75
-
You may switch to GPT-4 which performs better, but costs ~x15 times more 🤠
133
+
Simply run any of the variable above like this:
76
134
77
135
```sh
78
-
oc config setmodel=gpt-4
136
+
oco config set OCO_OPENAI_API_KEY=gpt-4
79
137
```
80
138
81
-
Make sure you do lowercase `gpt-4`.
82
-
83
-
### Preface commits with emoji 🤠
139
+
Configure [GitMoji](https://gitmoji.dev/) to preface a message.
84
140
85
-
[GitMoji](https://gitmoji.dev/) convention is used.
141
+
```sh
142
+
oco config set OCO_EMOJI=true
143
+
```
86
144
87
-
To add emoji:
145
+
To remove preface emoji:
88
146
89
147
```sh
90
-
oc config setemoji=true
148
+
oco config set OCO_EMOJI=false
91
149
```
92
150
93
-
To remove emoji:
151
+
### Switch to Azure OpenAI
152
+
153
+
By default OpenCommit uses [OpenAI](https://openai.com).
154
+
155
+
You could switch to [Azure OpenAI Service](https://learn.microsoft.com/azure/cognitive-services/openai/)🚀
94
156
95
157
```sh
96
-
oc config setemoji=false
158
+
opencommit config set OPENAI_API_TYPE=azure
97
159
```
98
160
99
-
### Postface commits with descriptions of changes
161
+
Of course need to set 'OPENAI_API_KEY'. And also need to set the
162
+
'OPENAI_BASE_PATH'for the endpoint and set the deployment name to
163
+
'model'.
164
+
165
+
### Switch to Azure OpenAI
166
+
167
+
By default OpenCommit uses [OpenAI](https://openai.com).
100
168
101
-
To add descriptions:
169
+
You could switch to [Azure OpenAI Service](https://learn.microsoft.com/azure/cognitive-services/openai/)🚀
102
170
103
171
```sh
104
-
oc config setdescription=true
172
+
opencommit config set OPENAI_API_TYPE=azure
105
173
```
106
174
107
-
To remove description:
175
+
Of course need to set 'OPENAI_API_KEY'. And also need to set the
176
+
'OPENAI_BASE_PATH'for the endpoint and set the deployment name to
177
+
'model'.
178
+
179
+
### Switch to GPT-4
180
+
181
+
By default OpenCommit uses GPT-3.5-turbo (ChatGPT).
182
+
183
+
You may switch to GPT-4 which performs better, but costs ~x15 times more 🤠
108
184
109
185
```sh
110
-
oc config setdescription=false
186
+
oco config set OCO_MODEL=gpt-4
111
187
```
112
188
113
-
### Internationalization support
189
+
Make sure you do lowercase `gpt-4` and you have API access to the 4th model. Even if you have ChatGPT+ it doesn't necessarily mean that you have API access to GPT-4.
190
+
191
+
## Locale configuration
114
192
115
-
To specify the language used to generate commit messages:
193
+
To globally specify the language used to generate commit messages:
116
194
117
195
```sh
118
196
# de, German ,Deutsch
119
-
oc config setlanguage=de
120
-
oc config setlanguage=German
121
-
oc config setlanguage=Deutsch
197
+
oco config set OCO_LANGUAGE=de
198
+
oco config set OCO_LANGUAGE=German
199
+
oco config set OCO_LANGUAGE=Deutsch
122
200
123
201
# fr, French, française
124
-
oc config setlanguage=fr
125
-
oc config setlanguage=French
126
-
oc config setlanguage=française
202
+
oco config set OCO_LANGUAGE=fr
203
+
oco config set OCO_LANGUAGE=French
204
+
oco config set OCO_LANGUAGE=française
127
205
```
128
206
129
-
The default language set is **English**
207
+
The default language set is **English**
130
208
All available languages are currently listed in the [i18n](https://github.com/di-sukharev/opencommit/tree/master/src/i18n) folder
131
209
132
210
### Push to git
@@ -138,10 +216,10 @@ oc config set gitpush=false
138
216
139
217
### Git flags
140
218
141
-
The `opencommit` or `oc` 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 `oc`.
219
+
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`.
142
220
143
221
```sh
144
-
oc --no-verify
222
+
oco --no-verify
145
223
```
146
224
147
225
is translated to :
@@ -163,20 +241,20 @@ This is useful for preventing opencommit from uploading artifacts and large file
163
241
164
242
By default, opencommit ignores files matching: `*-lock.*`and `*.lock`
165
243
166
-
## Git hook
244
+
## Git hook (KILLER FEATURE)
167
245
168
246
You can set OpenCommit as Git [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. Hook integrates with you IDE Source Control and allows you edit the message before commit.
0 commit comments