Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ suggest 10 commit messages based on the following diff:
{{diff}}
commit messages should:
- follow conventional commits
- message format should be: <type>[scope]: <description>
- message format should be: <type>(scope): <description>

examples:
- fix(authentication): add password regex pattern
Expand Down
18 changes: 11 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function run(diff: string) {
// TODO: we should use a good tokenizer here
const diffTokens = diff.split(" ").length;
if (diffTokens > 2000) {
console.log(`Diff is way too bug. Truncating to 700 tokens. It may help`);
console.log(`Diff is way too big. Truncating to 700 tokens. It may help`);
diff = diff.split(" ").slice(0, 700).join(" ");
}

Expand All @@ -65,17 +65,21 @@ async function run(diff: string) {
});

if (answer.message === CUSTOM_MESSAGE_OPTION) {
execSync("git commit", { stdio: "inherit" });
execSync("git commit", {stdio: "inherit"});
return;
} else {
execSync(`git commit -m '${escapeCommitMessage(answer.message)}'`, {
stdio: "inherit",
});
const commitMessage = escapeCommitMessage(answer.message);
const commitCommand = `git commit -m "${commitMessage}"`;
execSync(commitCommand, {stdio: 'inherit'});
return;
}
} catch (e) {
console.log("Aborted.");
console.log(e);
console.log("Error:", e.message || e);
if (e.status !== null && e.status !== 0) {
console.error("Git commit failed with status code:", e.status);
} else {
console.error("Aborted.");
}
process.exit(1);
}
}
Expand Down