feat: add support for .opencommitignore file (#22)
* feat: add support for .opencommitignore
This commit is contained in:
@@ -11,3 +11,4 @@ logfile.log
|
|||||||
uncaughtExceptions.log
|
uncaughtExceptions.log
|
||||||
.vscode
|
.vscode
|
||||||
src/*.json
|
src/*.json
|
||||||
|
.idea
|
||||||
@@ -98,6 +98,18 @@ is translated to :
|
|||||||
git commit -m "${generatedMessage}" --no-verify
|
git commit -m "${generatedMessage}" --no-verify
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Ignore files
|
||||||
|
You can ignore files from submission to OpenAI by creating a `.opencommitignore` file. For example:
|
||||||
|
|
||||||
|
```ignorelang
|
||||||
|
path/to/large-asset.zip
|
||||||
|
**/*.jpg
|
||||||
|
```
|
||||||
|
|
||||||
|
This is useful for preventing opencommit from uploading artifacts and large files.
|
||||||
|
|
||||||
|
By default, opencommit ignores files matching: `*-lock.*` and `*.lock`
|
||||||
|
|
||||||
## Git hook
|
## Git hook
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|||||||
Generated
+3
-3
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "opencommit",
|
"name": "opencommit",
|
||||||
"version": "1.1.11",
|
"version": "1.1.16",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "opencommit",
|
"name": "opencommit",
|
||||||
"version": "1.1.11",
|
"version": "1.1.16",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clack/prompts": "^0.6.1",
|
"@clack/prompts": "^0.6.1",
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
"chalk": "^5.2.0",
|
"chalk": "^5.2.0",
|
||||||
"cleye": "^1.3.2",
|
"cleye": "^1.3.2",
|
||||||
"execa": "^7.0.0",
|
"execa": "^7.0.0",
|
||||||
|
"ignore": "^5.2.4",
|
||||||
"ini": "^3.0.1",
|
"ini": "^3.0.1",
|
||||||
"inquirer": "^9.1.4",
|
"inquirer": "^9.1.4",
|
||||||
"openai": "^3.2.1"
|
"openai": "^3.2.1"
|
||||||
@@ -1880,7 +1881,6 @@
|
|||||||
"version": "5.2.4",
|
"version": "5.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",
|
||||||
"integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==",
|
"integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 4"
|
"node": ">= 4"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "opencommit",
|
"name": "opencommit",
|
||||||
"version": "1.1.11",
|
"version": "1.1.16",
|
||||||
"description": "GPT CLI to auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
|
"description": "GPT CLI to auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"git",
|
"git",
|
||||||
@@ -64,6 +64,7 @@
|
|||||||
"chalk": "^5.2.0",
|
"chalk": "^5.2.0",
|
||||||
"cleye": "^1.3.2",
|
"cleye": "^1.3.2",
|
||||||
"execa": "^7.0.0",
|
"execa": "^7.0.0",
|
||||||
|
"ignore": "^5.2.4",
|
||||||
"ini": "^3.0.1",
|
"ini": "^3.0.1",
|
||||||
"inquirer": "^9.1.4",
|
"inquirer": "^9.1.4",
|
||||||
"openai": "^3.2.1"
|
"openai": "^3.2.1"
|
||||||
|
|||||||
+21
-3
@@ -1,5 +1,7 @@
|
|||||||
import { execa } from 'execa';
|
import { execa } from 'execa';
|
||||||
import { outro, spinner } from '@clack/prompts';
|
import { outro, spinner } from '@clack/prompts';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
import ignore, { Ignore } from 'ignore';
|
||||||
|
|
||||||
export const assertGitRepo = async () => {
|
export const assertGitRepo = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -13,16 +15,32 @@ export const assertGitRepo = async () => {
|
|||||||
// (file) => `:(exclude)${file}`
|
// (file) => `:(exclude)${file}`
|
||||||
// );
|
// );
|
||||||
|
|
||||||
|
export const getOpenCommitIgnore = (): Ignore => {
|
||||||
|
const ig = ignore();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ig.add(readFileSync('.opencommitignore').toString().split('\n'));
|
||||||
|
} catch(e) {}
|
||||||
|
|
||||||
|
return ig;
|
||||||
|
}
|
||||||
|
|
||||||
export const getStagedFiles = async (): Promise<string[]> => {
|
export const getStagedFiles = async (): Promise<string[]> => {
|
||||||
const { stdout: files } = await execa('git', [
|
const { stdout: files } = await execa('git', [
|
||||||
'diff',
|
'diff',
|
||||||
'--name-only',
|
'--name-only',
|
||||||
'--cached'
|
'--cached',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!files) return [];
|
const filesList = files.split('\n');
|
||||||
|
|
||||||
return files.split('\n').sort();
|
|
||||||
|
const ig = getOpenCommitIgnore();
|
||||||
|
const allowedFiles = filesList.filter(file => !ig.ignores(file));
|
||||||
|
|
||||||
|
if (!allowedFiles) return [];
|
||||||
|
|
||||||
|
return allowedFiles.sort();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getChangedFiles = async (): Promise<string[]> => {
|
export const getChangedFiles = async (): Promise<string[]> => {
|
||||||
|
|||||||
Reference in New Issue
Block a user