opencommit 2.0.15 → 2.0.17

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 CHANGED
@@ -18,7 +18,70 @@
18
18
 
19
19
  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
+ ### Automatic 1 click setup
28
+
29
+ You can simply [setup the action automatically via the GitHub Marketplace](TODO).
30
+
31
+ ### Manual 3 clicks setup
32
+
33
+ Create a file `.github/workflows/opencommit.yml` with contents below:
34
+
35
+ ```yml
36
+ name: 'OpenCommit'
37
+
38
+ on:
39
+ push:
40
+ # this list of branches is often enough,
41
+ # but you may still ignore other public branches
42
+ branches-ignore: [main master dev development release]
43
+
44
+ jobs:
45
+ opencommit:
46
+ name: OpenCommit
47
+ runs-on: ubuntu-latest
48
+ permissions: write-all
49
+ steps:
50
+ - name: Setup Node.js Environment
51
+ uses: actions/setup-node@v2
52
+ with:
53
+ node-version: '16'
54
+ - uses: actions/checkout@v3
55
+ with:
56
+ fetch-depth: 0
57
+ - uses: di-sukharev/opencommit@github-action
58
+ with:
59
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60
+
61
+ env:
62
+ # set openAI api key in repo actions secrets,
63
+ # for openAI keys go to: https://platform.openai.com/account/api-keys
64
+ # for repo secret go to: <your_repo_url>/settings/secrets/actions
65
+ OCO_OPENAI_API_KEY: ${{ secrets.OCO_OPENAI_API_KEY }}
66
+
67
+ # customization
68
+ OCO_OPENAI_MAX_TOKENS: 500
69
+ OCO_OPENAI_BASE_PATH: ''
70
+ OCO_DESCRIPTION: false
71
+ OCO_EMOJI: false
72
+ OCO_MODEL: gpt-3.5-turbo
73
+ OCO_LANGUAGE: en
74
+ ```
75
+
76
+ That is it. Now when you push to any branch in your repo — all NEW commits are being improved by never-tired-AI.
77
+
78
+ Make sure you exclude public collaboration branches (`main`, `dev`, `etc`) in `branches-ignore`, so OpenCommit does not rebase commits there when improving the messages.
79
+
80
+ 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.
81
+
82
+ ## Setup OpenCommit as a CLI
83
+
84
+ You can use OpenCommit by simply running it via CLI like this `oc`. 2 seconds and your staged changes are committed with a meaningful message.
22
85
 
23
86
  1. Install OpenCommit globally to use in any repository:
24
87
 
@@ -31,7 +94,7 @@ All the commits in this repo are done with OpenCommit — look into [the commits
31
94
  3. Set the key to OpenCommit config:
32
95
 
33
96
  ```sh
34
- opencommit config set OPENAI_API_KEY=<your_api_key>
97
+ opencommit config set OCO_OPENAI_API_KEY=<your_api_key>
35
98
  ```
36
99
 
37
100
  Your api key is stored locally in `~/.opencommit` config file.
@@ -52,82 +115,70 @@ git add <files...>
52
115
  oc
53
116
  ```
54
117
 
55
- ## Features
118
+ ## Configuration
56
119
 
57
- ### Switch to GPT-4
120
+ ### Local per repo configuration
58
121
 
59
- By default OpenCommit uses GPT-3.5-turbo (ChatGPT).
60
-
61
- You may switch to GPT-4 which performs better, but costs ~x15 times more 🤠
122
+ Create an `.env` file and add OpenCommit config variables there like this:
62
123
 
63
- ```sh
64
- oc config set model=gpt-4
124
+ ```env
125
+ OCO_OPENAI_API_KEY=<your openAI API token>
126
+ OCO_OPENAI_MAX_TOKENS=<max response tokens from openAI API>
127
+ OCO_OPENAI_BASE_PATH=<may be used to set proxy path to openAI api>
128
+ OCO_DESCRIPTION=<postface a message with ~3 sentences description>
129
+ OCO_EMOJI=<add GitMoji>
130
+ OCO_MODEL=<either gpt-3.5-turbo or gpt-4>
131
+ OCO_LANGUAGE=<locale, scroll to the bottom to see options>
65
132
  ```
66
133
 
67
- Make sure you do lowercase `gpt-4`.
68
-
69
- ### Preface commits with emoji 🤠
134
+ ### Global config for all repos
70
135
 
71
- [GitMoji](https://gitmoji.dev/) convention is used.
136
+ 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.
72
137
 
73
- To add emoji:
138
+ Simply run any of the variable above like this:
74
139
 
75
140
  ```sh
76
- oc config set emoji=true
141
+ oc config set OCO_OPENAI_API_KEY=gpt-4
77
142
  ```
78
143
 
79
- To remove emoji:
144
+ Configure [GitMoji](https://gitmoji.dev/) to preface a message.
80
145
 
81
146
  ```sh
82
- oc config set emoji=false
147
+ oc config set OCO_EMOJI=true
83
148
  ```
84
149
 
85
- ### Postface commits with descriptions of changes
86
-
87
- To add descriptions:
150
+ To remove preface emoji:
88
151
 
89
152
  ```sh
90
- oc config set description=true
153
+ oc config set OCO_EMOJI=false
91
154
  ```
92
155
 
93
- To remove description:
94
-
95
- ```sh
96
- oc config set description=false
97
- ```
98
-
99
- ### Configure openAI maxTokens param
156
+ ### Switch to GPT-4
100
157
 
101
- Default value for `maxTokens` is 196, sometimes you can get 400 error if request+response exceeds `maxToken` parameter.
158
+ By default OpenCommit uses GPT-3.5-turbo (ChatGPT).
102
159
 
103
- so you can increase it:
160
+ You may switch to GPT-4 which performs better, but costs ~x15 times more 🤠
104
161
 
105
162
  ```sh
106
- oc config set OPENAI_MAX_TOKENS=<number>
163
+ oc config set OCO_MODEL=gpt-4
107
164
  ```
108
165
 
109
- ### Configure BASE_PATH for openAI api
110
-
111
- if you want to call GPT via proxy — you can change `BASE_PATH` parameter:
112
-
113
- ```sh
114
- oc config set OPENAI_BASE_PATH=<string>
115
- ```
166
+ 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.
116
167
 
117
- ### Internationalization support
168
+ ## Locale configuration
118
169
 
119
- To specify the language used to generate commit messages:
170
+ To globally specify the language used to generate commit messages:
120
171
 
121
172
  ```sh
122
173
  # de, German ,Deutsch
123
- oc config set language=de
124
- oc config set language=German
125
- oc config set language=Deutsch
174
+ oc config set OCO_LANGUAGE=de
175
+ oc config set OCO_LANGUAGE=German
176
+ oc config set OCO_LANGUAGE=Deutsch
126
177
 
127
178
  # fr, French, française
128
- oc config set language=fr
129
- oc config set language=French
130
- oc config set language=française
179
+ oc config set OCO_LANGUAGE=fr
180
+ oc config set OCO_LANGUAGE=French
181
+ oc config set OCO_LANGUAGE=française
131
182
  ```
132
183
 
133
184
  The default language set is **English**
@@ -160,7 +211,7 @@ This is useful for preventing opencommit from uploading artifacts and large file
160
211
 
161
212
  By default, opencommit ignores files matching: `*-lock.*` and `*.lock`
162
213
 
163
- ## Git hook
214
+ ## Git hook (KILLER FEATURE)
164
215
 
165
216
  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.
166
217