Compare commits

..

2 Commits

Author SHA1 Message Date
di-sukharev
8c1eb4a5ad 1.1.29 2023-03-29 11:31:35 +08:00
di-sukharev
bafe7e9ede refactor(prepare-commit-msg-hook.ts): simplify conditional statements
The conditional statements in the prepareCommitMessageHook function have been simplified to improve readability. The first conditional statement now checks if there are no staged files and no changed files, and if so, it will output a message and exit the process. The second conditional statement now checks if there are no staged files but there are changed files, and if so, it will add the changed files to the staging area.
2023-03-29 11:31:27 +08:00
3 changed files with 6 additions and 5 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "opencommit",
"version": "1.1.28",
"version": "1.1.29",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "opencommit",
"version": "1.1.28",
"version": "1.1.29",
"license": "MIT",
"dependencies": {
"@clack/prompts": "^0.6.1",

View File

@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "1.1.28",
"version": "1.1.29",
"description": "GPT CLI to auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
"keywords": [
"git",

View File

@@ -20,12 +20,13 @@ export const prepareCommitMessageHook = async () => {
const stagedFiles = await getStagedFiles();
const changedFiles = await getChangedFiles();
if (!stagedFiles && changedFiles) await gitAdd({ files: changedFiles });
else {
if (!stagedFiles && !changedFiles) {
outro('No changes detected, write some code and run `oc` again');
process.exit(1);
}
if (!stagedFiles && changedFiles) await gitAdd({ files: changedFiles });
const staged = await getStagedFiles();
if (!staged) return;