The assert statement was added to ensure that the imported packageJSON is of type JSON. This prevents any potential runtime errors that may occur if the imported file is not of the expected type. * 🐛 fix(generateCommitMessageFromGitDiff.ts): adjust MAX_REQ_TOKENS to account for INIT_MESSAGES_PROMPT_LENGTH * 💄 style(generateCommitMessageFromGitDiff.ts): remove unnecessary separator variable The MAX_REQ_TOKENS constant was not accounting for the length of the INIT_MESSAGES_PROMPT, which caused the function to fail when the diff length was close to the limit. This has been fixed by adjusting the constant to include the prompt length. The separator variable was not being used and has been removed for clarity. * 🚀 chore(tsconfig.json): update compiler options The target compiler option has been updated to ESNext to allow for the use of the latest ECMAScript features. The lib compiler option has been updated to include ES6 in addition to ES5. The module compiler option has been updated to ESNext to allow for the use of the latest module syntax.
Examples
Look into the commits to see how OpenCommit works. Emoji and long commit description text is configurable.
Setup
The minimum supported version of Node.js is the latest v14. Check your Node.js version with
node --version.
-
Install opencommit globally to use in any repository:
npm install -g opencommit -
Get your API key from OpenAI
-
Set the key to opencommit config:
opencommit config set OPENAI_API_KEY=<your token>Your token isn't sent to anyone, it's saved in
~/.opencommitconfig file.
Usage
You can call opencommit directly to generate a commit message for your staged changes:
git add <files...>
opencommit
You can also use the oc shortcut:
git add <files...>
oc
Features
Preface commits with emoji 🤠
GitMoji convention is used.
To add emoji:
oc config set emoji=true
To remove emoji:
oc config set emoji=false
Postface commits with descriptions of changes
To add descriptions:
oc config set description=true
To remove description:
oc config set description=false
Git hook
You can set opencommit as Git prepare-commit-msg hook. Hook integrates with you IDE Source Control and allows you edit the message before commit.
To set the hook:
oc hook set
To unset the hook:
oc hook unset
To use the hook:
git add <files...>
git commit
Or follow the process of your IDE Source Control feature, when it calls git commit command — OpenCommit will integrate into the flow.
Payments
You pay for your own requests to OpenAI API. OpenCommit uses ChatGPT official model, that is ~10x times cheaper than GPT-3.