diff --git a/src/commands/prepare-commit-msg-hook.ts b/src/commands/prepare-commit-msg-hook.ts index afde485..00aa835 100644 --- a/src/commands/prepare-commit-msg-hook.ts +++ b/src/commands/prepare-commit-msg-hook.ts @@ -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;