Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config.ts): add skipCommitMessageCheck config key #19

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/commands/config.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,8 @@ import { COMMANDS } from '../CommandsEnum';
export enum CONFIG_KEYS {
OPENAI_API_KEY = 'OPENAI_API_KEY',
description = 'description',
emoji = 'emoji'
emoji = 'emoji',
skipCommitMessageCheck = 'skipCommitMessageCheck'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename it to skipCommitMsgHookSourceCheck?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome @Lars- thanks! could you change base branch to dev instead of master pls <3

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also done!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lars- there is a conflict, could you solve pls and let's merge it!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue wasn't there when I sent the PR, so you may change it

}

export enum CONFIG_MODES {
@@ -64,7 +65,16 @@ export const configValidators = {
);

return value;
}
},
[CONFIG_KEYS.skipCommitMessageCheck](value: any) {
validateConfig(
CONFIG_KEYS.skipCommitMessageCheck,
typeof value === 'boolean',
'Must be true or false'
);

return value;
},
};

export type ConfigType = {
7 changes: 4 additions & 3 deletions src/commands/prepare-commit-msg-hook.ts
Original file line number Diff line number Diff line change
@@ -15,16 +15,17 @@ export const prepareCommitMessageHook = async () => {
);
}

if (commitSource) return;
const config = getConfig();

// Skip commit message check if the user has set the skipCommitMessageCheck flag to true
if (!config?.skipCommitMessageCheck && commitSource) return;

const staged = await getStagedGitDiff();

if (!staged) return;

intro('opencommit');

const config = getConfig();

if (!config?.OPENAI_API_KEY) {
throw new Error(
'No OPEN_AI_API exists. Set your OPEN_AI_API=<key> in ~/.opencommit'