mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-14 16:18:02 -05:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75fa04efd4 | ||
|
|
93019139fb | ||
|
|
ce47c1fe81 | ||
|
|
a880dd6bd2 | ||
|
|
f193bb1d96 | ||
|
|
4cc34dfa5f | ||
|
|
d034238505 | ||
|
|
25acb1c219 | ||
|
|
44c9d48eae | ||
|
|
702eab9ec0 | ||
|
|
e8be3858ab | ||
|
|
50e7cd3576 | ||
|
|
4f57201e98 | ||
|
|
009462f92c | ||
|
|
34775e9e69 | ||
|
|
3f3043c48e | ||
|
|
820422760a | ||
|
|
b40657c1a7 | ||
|
|
dcd8f52be3 |
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"trailingComma": "none",
|
"singleQuote": true,
|
||||||
"singleQuote": true
|
"trailingComma": "none"
|
||||||
}
|
}
|
||||||
|
|||||||
35
README.md
35
README.md
@@ -37,6 +37,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
opencommit:
|
opencommit:
|
||||||
|
timeout-minutes: 10
|
||||||
name: OpenCommit
|
name: OpenCommit
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
@@ -75,7 +76,7 @@ Interactive rebase (`rebase -i`) changes commit SHA, so commit history in remote
|
|||||||
|
|
||||||
## Setup OpenCommit as a CLI
|
## Setup OpenCommit as a CLI
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
1. Install OpenCommit globally to use in any repository:
|
1. Install OpenCommit globally to use in any repository:
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ git add <files...>
|
|||||||
opencommit
|
opencommit
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also use the `oc` shortcut:
|
You can also use the `oco` shortcut:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git add <files...>
|
git add <files...>
|
||||||
@@ -132,19 +133,19 @@ Local config still has more priority as Global config, but you may set `OCO_MODE
|
|||||||
Simply run any of the variable above like this:
|
Simply run any of the variable above like this:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
oc config set OCO_OPENAI_API_KEY=gpt-4
|
oco config set OCO_OPENAI_API_KEY=gpt-4
|
||||||
```
|
```
|
||||||
|
|
||||||
Configure [GitMoji](https://gitmoji.dev/) to preface a message.
|
Configure [GitMoji](https://gitmoji.dev/) to preface a message.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
oc config set OCO_EMOJI=true
|
oco config set OCO_EMOJI=true
|
||||||
```
|
```
|
||||||
|
|
||||||
To remove preface emoji:
|
To remove preface emoji:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
oc config set OCO_EMOJI=false
|
oco config set OCO_EMOJI=false
|
||||||
```
|
```
|
||||||
|
|
||||||
### Switch to GPT-4
|
### Switch to GPT-4
|
||||||
@@ -154,7 +155,7 @@ By default OpenCommit uses GPT-3.5-turbo (ChatGPT).
|
|||||||
You may switch to GPT-4 which performs better, but costs ~x15 times more 🤠
|
You may switch to GPT-4 which performs better, but costs ~x15 times more 🤠
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
oc config set OCO_MODEL=gpt-4
|
oco config set OCO_MODEL=gpt-4
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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.
|
||||||
@@ -165,25 +166,25 @@ To globally specify the language used to generate commit messages:
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
# de, German ,Deutsch
|
# de, German ,Deutsch
|
||||||
oc config set OCO_LANGUAGE=de
|
oco config set OCO_LANGUAGE=de
|
||||||
oc config set OCO_LANGUAGE=German
|
oco config set OCO_LANGUAGE=German
|
||||||
oc config set OCO_LANGUAGE=Deutsch
|
oco config set OCO_LANGUAGE=Deutsch
|
||||||
|
|
||||||
# fr, French, française
|
# fr, French, française
|
||||||
oc config set OCO_LANGUAGE=fr
|
oco config set OCO_LANGUAGE=fr
|
||||||
oc config set OCO_LANGUAGE=French
|
oco config set OCO_LANGUAGE=French
|
||||||
oc config set OCO_LANGUAGE=française
|
oco config set OCO_LANGUAGE=française
|
||||||
```
|
```
|
||||||
|
|
||||||
The default language set is **English**
|
The default language set is **English**
|
||||||
All available languages are currently listed in the [i18n](https://github.com/di-sukharev/opencommit/tree/master/src/i18n) folder
|
All available languages are currently listed in the [i18n](https://github.com/di-sukharev/opencommit/tree/master/src/i18n) folder
|
||||||
|
|
||||||
### Git flags
|
### Git flags
|
||||||
|
|
||||||
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`.
|
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`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
oc --no-verify
|
oco --no-verify
|
||||||
```
|
```
|
||||||
|
|
||||||
is translated to :
|
is translated to :
|
||||||
@@ -212,13 +213,13 @@ You can set OpenCommit as Git [`prepare-commit-msg`](https://git-scm.com/docs/gi
|
|||||||
To set the hook:
|
To set the hook:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
oc hook set
|
oco hook set
|
||||||
```
|
```
|
||||||
|
|
||||||
To unset the hook:
|
To unset the hook:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
oc hook unset
|
oco hook unset
|
||||||
```
|
```
|
||||||
|
|
||||||
To use the hook:
|
To use the hook:
|
||||||
|
|||||||
42
out/cli.cjs
42
out/cli.cjs
@@ -16272,7 +16272,7 @@ function G3(t, e2) {
|
|||||||
// package.json
|
// package.json
|
||||||
var package_default = {
|
var package_default = {
|
||||||
name: "opencommit",
|
name: "opencommit",
|
||||||
version: "2.0.17",
|
version: "2.2.1",
|
||||||
description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
|
description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
|
||||||
keywords: [
|
keywords: [
|
||||||
"git",
|
"git",
|
||||||
@@ -16289,7 +16289,6 @@ var package_default = {
|
|||||||
main: "cli.js",
|
main: "cli.js",
|
||||||
bin: {
|
bin: {
|
||||||
opencommit: "./out/cli.cjs",
|
opencommit: "./out/cli.cjs",
|
||||||
oc: "./out/cli.cjs",
|
|
||||||
oco: "./out/cli.cjs"
|
oco: "./out/cli.cjs"
|
||||||
},
|
},
|
||||||
repository: {
|
repository: {
|
||||||
@@ -16314,7 +16313,7 @@ var package_default = {
|
|||||||
start: "node ./out/cli.cjs",
|
start: "node ./out/cli.cjs",
|
||||||
dev: "ts-node ./src/cli.ts",
|
dev: "ts-node ./src/cli.ts",
|
||||||
build: "rimraf out && node esbuild.config.js",
|
build: "rimraf out && node esbuild.config.js",
|
||||||
deploy: "npm run build && npm version patch && npm publish --tag latest",
|
deploy: "npm run build:push && npm version patch && git push && git push --tags && npm publish --tag latest",
|
||||||
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
|
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
|
||||||
lint: "eslint src --ext ts && tsc --noEmit",
|
lint: "eslint src --ext ts && tsc --noEmit",
|
||||||
format: "prettier --write src"
|
format: "prettier --write src"
|
||||||
@@ -21686,7 +21685,7 @@ var [command, mode] = process.argv.slice(2);
|
|||||||
if (!apiKey && command !== "config" && mode !== "set" /* set */) {
|
if (!apiKey && command !== "config" && mode !== "set" /* set */) {
|
||||||
ae("opencommit");
|
ae("opencommit");
|
||||||
ce(
|
ce(
|
||||||
"OCO_OPENAI_API_KEY is not set, please run `oc config set OCO_OPENAI_API_KEY=<your token>. Make sure you add payment details, so API works.`"
|
"OCO_OPENAI_API_KEY is not set, please run `oco config set OCO_OPENAI_API_KEY=<your token>. Make sure you add payment details, so API works.`"
|
||||||
);
|
);
|
||||||
ce(
|
ce(
|
||||||
"For help look into README https://github.com/di-sukharev/opencommit#setup"
|
"For help look into README https://github.com/di-sukharev/opencommit#setup"
|
||||||
@@ -21733,6 +21732,17 @@ var OpenAi = class {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
var getOpenCommitLatestVersion = async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await axios_default.get(
|
||||||
|
"https://unpkg.com/opencommit/package.json"
|
||||||
|
);
|
||||||
|
return data.version;
|
||||||
|
} catch (_6) {
|
||||||
|
ce("Error while getting the latest version of opencommit");
|
||||||
|
return void 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
var api = new OpenAi();
|
var api = new OpenAi();
|
||||||
|
|
||||||
// src/utils/tokenCount.ts
|
// src/utils/tokenCount.ts
|
||||||
@@ -21903,7 +21913,7 @@ var prepareCommitMessageHook = async (isStageAllFlag = false) => {
|
|||||||
if (changedFiles)
|
if (changedFiles)
|
||||||
await gitAdd({ files: changedFiles });
|
await gitAdd({ files: changedFiles });
|
||||||
else {
|
else {
|
||||||
ce("No changes detected, write some code and run `oc` again");
|
ce("No changes detected, write some code and run `oco` again");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22037,7 +22047,7 @@ async function commit(extraArgs2 = [], isStageAllFlag = false) {
|
|||||||
if (changedFiles2)
|
if (changedFiles2)
|
||||||
await gitAdd({ files: changedFiles2 });
|
await gitAdd({ files: changedFiles2 });
|
||||||
else {
|
else {
|
||||||
ce("No changes detected, write some code and run `oc` again");
|
ce("No changes detected, write some code and run `oco` again");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22095,6 +22105,25 @@ ${stagedFiles.map((file) => ` ${file}`).join("\n")}`
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// src/utils/checkIsLatestVersion.ts
|
||||||
|
var checkIsLatestVersion = async () => {
|
||||||
|
const latestVersion = await getOpenCommitLatestVersion();
|
||||||
|
if (latestVersion) {
|
||||||
|
const currentVersion = package_default.version;
|
||||||
|
if (currentVersion !== latestVersion) {
|
||||||
|
console.warn(
|
||||||
|
source_default.yellow(
|
||||||
|
`
|
||||||
|
You are not using the latest stable version of OpenCommit with new features and bug fixes.
|
||||||
|
Current version: ${currentVersion}. Latest version: ${latestVersion}.
|
||||||
|
\u{1F680} To update run: npm i -g opencommit@latest.
|
||||||
|
`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// src/cli.ts
|
// src/cli.ts
|
||||||
var extraArgs = process.argv.slice(2);
|
var extraArgs = process.argv.slice(2);
|
||||||
Z2(
|
Z2(
|
||||||
@@ -22107,6 +22136,7 @@ Z2(
|
|||||||
help: { description: package_default.description }
|
help: { description: package_default.description }
|
||||||
},
|
},
|
||||||
async () => {
|
async () => {
|
||||||
|
await checkIsLatestVersion();
|
||||||
if (await isHookCalled()) {
|
if (await isHookCalled()) {
|
||||||
prepareCommitMessageHook();
|
prepareCommitMessageHook();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -26973,7 +26973,7 @@ var [command, mode] = process.argv.slice(2);
|
|||||||
if (!apiKey && command !== "config" && mode !== "set" /* set */) {
|
if (!apiKey && command !== "config" && mode !== "set" /* set */) {
|
||||||
ae("opencommit");
|
ae("opencommit");
|
||||||
ce(
|
ce(
|
||||||
"OCO_OPENAI_API_KEY is not set, please run `oc config set OCO_OPENAI_API_KEY=<your token>. Make sure you add payment details, so API works.`"
|
"OCO_OPENAI_API_KEY is not set, please run `oco config set OCO_OPENAI_API_KEY=<your token>. Make sure you add payment details, so API works.`"
|
||||||
);
|
);
|
||||||
ce(
|
ce(
|
||||||
"For help look into README https://github.com/di-sukharev/opencommit#setup"
|
"For help look into README https://github.com/di-sukharev/opencommit#setup"
|
||||||
|
|||||||
5
package-lock.json
generated
5
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "opencommit",
|
"name": "opencommit",
|
||||||
"version": "2.0.18",
|
"version": "2.2.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "opencommit",
|
"name": "opencommit",
|
||||||
"version": "2.0.18",
|
"version": "2.2.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
@@ -26,7 +26,6 @@
|
|||||||
"openai": "^3.2.1"
|
"openai": "^3.2.1"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"oc": "out/cli.cjs",
|
|
||||||
"oco": "out/cli.cjs",
|
"oco": "out/cli.cjs",
|
||||||
"opencommit": "out/cli.cjs"
|
"opencommit": "out/cli.cjs"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "opencommit",
|
"name": "opencommit",
|
||||||
"version": "2.0.18",
|
"version": "2.2.2",
|
||||||
"description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
|
"description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"git",
|
"git",
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
"main": "cli.js",
|
"main": "cli.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"opencommit": "./out/cli.cjs",
|
"opencommit": "./out/cli.cjs",
|
||||||
"oc": "./out/cli.cjs",
|
|
||||||
"oco": "./out/cli.cjs"
|
"oco": "./out/cli.cjs"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -42,7 +41,7 @@
|
|||||||
"start": "node ./out/cli.cjs",
|
"start": "node ./out/cli.cjs",
|
||||||
"dev": "ts-node ./src/cli.ts",
|
"dev": "ts-node ./src/cli.ts",
|
||||||
"build": "rimraf out && node esbuild.config.js",
|
"build": "rimraf out && node esbuild.config.js",
|
||||||
"deploy": "npm run build && npm version patch && npm publish --tag latest",
|
"deploy": "npm run build:push && npm version patch && git push && git push --tags && npm publish --tag latest",
|
||||||
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
|
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
|
||||||
"lint": "eslint src --ext ts && tsc --noEmit",
|
"lint": "eslint src --ext ts && tsc --noEmit",
|
||||||
"format": "prettier --write src"
|
"format": "prettier --write src"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ if (!apiKey && command !== 'config' && mode !== CONFIG_MODES.set) {
|
|||||||
intro('opencommit');
|
intro('opencommit');
|
||||||
|
|
||||||
outro(
|
outro(
|
||||||
'OCO_OPENAI_API_KEY is not set, please run `oc config set OCO_OPENAI_API_KEY=<your token>. Make sure you add payment details, so API works.`'
|
'OCO_OPENAI_API_KEY is not set, please run `oco config set OCO_OPENAI_API_KEY=<your token>. Make sure you add payment details, so API works.`'
|
||||||
);
|
);
|
||||||
outro(
|
outro(
|
||||||
'For help look into README https://github.com/di-sukharev/opencommit#setup'
|
'For help look into README https://github.com/di-sukharev/opencommit#setup'
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { configCommand } from './commands/config';
|
|||||||
import { hookCommand, isHookCalled } from './commands/githook.js';
|
import { hookCommand, isHookCalled } from './commands/githook.js';
|
||||||
import { prepareCommitMessageHook } from './commands/prepare-commit-msg-hook';
|
import { prepareCommitMessageHook } from './commands/prepare-commit-msg-hook';
|
||||||
import { commit } from './commands/commit';
|
import { commit } from './commands/commit';
|
||||||
// import { checkIsLatestVersion } from './utils/checkIsLatestVersion';
|
import { checkIsLatestVersion } from './utils/checkIsLatestVersion';
|
||||||
|
|
||||||
const extraArgs = process.argv.slice(2);
|
const extraArgs = process.argv.slice(2);
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ cli(
|
|||||||
help: { description: packageJSON.description }
|
help: { description: packageJSON.description }
|
||||||
},
|
},
|
||||||
async () => {
|
async () => {
|
||||||
// await checkIsLatestVersion();
|
await checkIsLatestVersion();
|
||||||
|
|
||||||
if (await isHookCalled()) {
|
if (await isHookCalled()) {
|
||||||
prepareCommitMessageHook();
|
prepareCommitMessageHook();
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ export async function commit(
|
|||||||
|
|
||||||
if (changedFiles) await gitAdd({ files: changedFiles });
|
if (changedFiles) await gitAdd({ files: changedFiles });
|
||||||
else {
|
else {
|
||||||
outro('No changes detected, write some code and run `oc` again');
|
outro('No changes detected, write some code and run `oco` again');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const prepareCommitMessageHook = async (
|
|||||||
|
|
||||||
if (changedFiles) await gitAdd({ files: changedFiles });
|
if (changedFiles) await gitAdd({ files: changedFiles });
|
||||||
else {
|
else {
|
||||||
outro('No changes detected, write some code and run `oc` again');
|
outro('No changes detected, write some code and run `oco` again');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user