diff --git a/.github/github-mark-white.png b/.github/github-mark-white.png
new file mode 100644
index 0000000..50b8175
Binary files /dev/null and b/.github/github-mark-white.png differ
diff --git a/README.md b/README.md
index 096d1b0..d692381 100644
--- a/README.md
+++ b/README.md
@@ -3,11 +3,12 @@
OpenCommit
Follow the bird
-
Auto-generate meaningful commits in 1 second
Killing lame commits with AI 🤯🔫
+ 🪩 Winner of GitHub 2023 HACKATHON
+
---
@@ -18,6 +19,26 @@
All the commits in this repo are authored by OpenCommit — look at [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emojis and long commit descriptions are configurable.
+## Setup OpenCommit as a CLI tool
+
+You can use OpenCommit by simply running it via the CLI like this `oco`. 2 seconds and your staged changes are committed with a meaningful message.
+
+1. Install OpenCommit globally to use in any repository:
+
+ ```sh
+ npm install -g opencommit
+ ```
+
+2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure that you add your payment details, so the API works.
+
+3. Set the key to OpenCommit config:
+
+ ```sh
+ opencommit config set OCO_OPENAI_API_KEY=
+ ```
+
+ Your API key is stored locally in the `~/.opencommit` config file.
+
## Setup OpenCommit as a GitHub Action 🔥
OpenCommit is now available as a GitHub Action which automatically improves all new commits messages when you push to remote!
@@ -74,26 +95,6 @@ Make sure you exclude public collaboration branches (`main`, `dev`, `etc`) in `b
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.
-## Setup OpenCommit as a CLI tool
-
-You can use OpenCommit by simply running it via the CLI like this `oco`. 2 seconds and your staged changes are committed with a meaningful message.
-
-1. Install OpenCommit globally to use in any repository:
-
- ```sh
- npm install -g opencommit
- ```
-
-2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure that you add your payment details, so the API works.
-
-3. Set the key to OpenCommit config:
-
- ```sh
- opencommit config set OCO_OPENAI_API_KEY=
- ```
-
- Your API key is stored locally in the `~/.opencommit` config file.
-
## Usage
You can call OpenCommit directly to generate a commit message for your staged changes:
@@ -149,9 +150,9 @@ To remove preface emojis:
oco config set OCO_EMOJI=false
```
-### Switch to GPT-4
+### Switch to GPT-4 or other models
-By default, OpenCommit uses GPT-3.5-turbo (ChatGPT).
+By default, OpenCommit uses `gpt-3.5-turbo-16k` model.
You may switch to GPT-4 which performs better, but costs ~x15 times more ðŸ¤
@@ -159,6 +160,12 @@ You may switch to GPT-4 which performs better, but costs ~x15 times more ðŸ¤
oco config set OCO_MODEL=gpt-4
```
+or for as a cheaper option:
+
+```sh
+oco config set OCO_MODEL=gpt-3.5-turbo
+```
+
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.
## Locale configuration
diff --git a/out/cli.cjs b/out/cli.cjs
index df2dd58..2ceca63 100755
--- a/out/cli.cjs
+++ b/out/cli.cjs
@@ -18717,10 +18717,7 @@ var getOpenCommitIgnore = () => {
return ig;
};
var getCoreHooksPath = async () => {
- const { stdout } = await execa("git", [
- "config",
- "core.hooksPath"
- ]);
+ const { stdout } = await execa("git", ["config", "core.hooksPath"]);
return stdout;
};
var getStagedFiles = async () => {
@@ -18764,11 +18761,11 @@ var gitAdd = async ({ files }) => {
};
var getDiff = async ({ files }) => {
const lockFiles = files.filter(
- (file) => file.includes(".lock") || file.includes("-lock.")
+ (file) => file.includes(".lock") || file.includes("-lock.") || file.includes(".svg") || file.includes(".png") || file.includes(".jpg") || file.includes(".jpeg") || file.includes(".webp") || file.includes(".gif")
);
if (lockFiles.length) {
ce(
- `Some files are '.lock' files which are excluded by default from 'git diff'. No commit messages are generated for this files:
+ `Some files are excluded by default from 'git diff'. No commit messages are generated for this files:
${lockFiles.join(
"\n"
)}`
diff --git a/src/commands/config.ts b/src/commands/config.ts
index 830d093..5cea43d 100644
--- a/src/commands/config.ts
+++ b/src/commands/config.ts
@@ -1,10 +1,10 @@
-import { command } from 'cleye';
-import { join as pathJoin } from 'path';
-import { parse as iniParse, stringify as iniStringify } from 'ini';
-import { existsSync, writeFileSync, readFileSync } from 'fs';
-import { homedir } from 'os';
import { intro, outro } from '@clack/prompts';
import chalk from 'chalk';
+import { command } from 'cleye';
+import { existsSync, readFileSync, writeFileSync } from 'fs';
+import { parse as iniParse, stringify as iniStringify } from 'ini';
+import { homedir } from 'os';
+import { join as pathJoin } from 'path';
import { COMMANDS } from '../CommandsEnum';
import { getI18nLocal } from '../i18n';
@@ -20,7 +20,7 @@ export enum CONFIG_KEYS {
OCO_EMOJI = 'OCO_EMOJI',
OCO_MODEL = 'OCO_MODEL',
OCO_LANGUAGE = 'OCO_LANGUAGE',
- OCO_MESSAGE_TEMPLATE_PLACEHOLDER = 'OCO_MESSAGE_TEMPLATE_PLACEHOLDER',
+ OCO_MESSAGE_TEMPLATE_PLACEHOLDER = 'OCO_MESSAGE_TEMPLATE_PLACEHOLDER'
}
export const DEFAULT_MODEL_TOKEN_LIMIT = 4096;
@@ -121,8 +121,13 @@ export const configValidators = {
[CONFIG_KEYS.OCO_MODEL](value: any) {
validateConfig(
CONFIG_KEYS.OCO_MODEL,
- ['gpt-3.5-turbo', 'gpt-4','gpt-3.5-turbo-16k'].includes(value),
- `${value} is not supported yet, use 'gpt-4' or 'gpt-3.5-turbo' (default)`
+ [
+ 'gpt-3.5-turbo',
+ 'gpt-4',
+ 'gpt-3.5-turbo-16k',
+ 'gpt-3.5-turbo-0613'
+ ].includes(value),
+ `${value} is not supported yet, use 'gpt-4', 'gpt-3.5-turbo-0613', 'gpt-3.5-turbo-0613' or 'gpt-3.5-turbo' (default)`
);
return value;
},
@@ -145,13 +150,16 @@ const configPath = pathJoin(homedir(), '.opencommit');
export const getConfig = (): ConfigType | null => {
const configFromEnv = {
OCO_OPENAI_API_KEY: process.env.OCO_OPENAI_API_KEY,
- OCO_OPENAI_MAX_TOKENS: process.env.OCO_OPENAI_MAX_TOKENS ? Number(process.env.OCO_OPENAI_MAX_TOKENS) : undefined,
+ OCO_OPENAI_MAX_TOKENS: process.env.OCO_OPENAI_MAX_TOKENS
+ ? Number(process.env.OCO_OPENAI_MAX_TOKENS)
+ : undefined,
OCO_OPENAI_BASE_PATH: process.env.OCO_OPENAI_BASE_PATH,
OCO_DESCRIPTION: process.env.OCO_DESCRIPTION === 'true' ? true : false,
OCO_EMOJI: process.env.OCO_EMOJI === 'true' ? true : false,
- OCO_MODEL: process.env.OCO_MODEL || 'gpt-3.5-turbo',
+ OCO_MODEL: process.env.OCO_MODEL || 'gpt-3.5-turbo-16k',
OCO_LANGUAGE: process.env.OCO_LANGUAGE || 'en',
- OCO_MESSAGE_TEMPLATE_PLACEHOLDER: process.env.OCO_MESSAGE_TEMPLATE_PLACEHOLDER || '$msg'
+ OCO_MESSAGE_TEMPLATE_PLACEHOLDER:
+ process.env.OCO_MESSAGE_TEMPLATE_PLACEHOLDER || '$msg'
};
const configExists = existsSync(configPath);
@@ -161,7 +169,10 @@ export const getConfig = (): ConfigType | null => {
const config = iniParse(configFile);
for (const configKey of Object.keys(config)) {
- if (!config[configKey] || ['null', 'undefined'].includes(config[configKey])) {
+ if (
+ !config[configKey] ||
+ ['null', 'undefined'].includes(config[configKey])
+ ) {
config[configKey] = undefined;
continue;
}
diff --git a/src/utils/git.ts b/src/utils/git.ts
index f8510df..3acd79a 100644
--- a/src/utils/git.ts
+++ b/src/utils/git.ts
@@ -25,13 +25,11 @@ export const getOpenCommitIgnore = (): Ignore => {
return ig;
};
-export const getCoreHooksPath = async(): Promise => {
- const { stdout } = await execa('git', [
- 'config',
- 'core.hooksPath']);
+export const getCoreHooksPath = async (): Promise => {
+ const { stdout } = await execa('git', ['config', 'core.hooksPath']);
return stdout;
-}
+};
export const getStagedFiles = async (): Promise => {
const { stdout: gitDir } = await execa('git', [
@@ -83,12 +81,20 @@ export const gitAdd = async ({ files }: { files: string[] }) => {
export const getDiff = async ({ files }: { files: string[] }) => {
const lockFiles = files.filter(
- (file) => file.includes('.lock') || file.includes('-lock.')
+ (file) =>
+ file.includes('.lock') ||
+ file.includes('-lock.') ||
+ file.includes('.svg') ||
+ file.includes('.png') ||
+ file.includes('.jpg') ||
+ file.includes('.jpeg') ||
+ file.includes('.webp') ||
+ file.includes('.gif')
);
if (lockFiles.length) {
outro(
- `Some files are '.lock' files which are excluded by default from 'git diff'. No commit messages are generated for this files:\n${lockFiles.join(
+ `Some files are excluded by default from 'git diff'. No commit messages are generated for this files:\n${lockFiles.join(
'\n'
)}`
);