fix(commands): commit crash upon missing HEAD (#19)
This commit is contained in:
@@ -69,28 +69,32 @@ const command = new Command("commit")
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const changedLines = (
|
||||
(
|
||||
await simpleGit().diff(["--numstat", stageAll ? "HEAD" : "--cached"])
|
||||
).match(/\d+/gm) || []
|
||||
).reduce((partialSum, num) => partialSum + Number(num), 0);
|
||||
try {
|
||||
const changedLines = (
|
||||
(
|
||||
await simpleGit().diff(["--numstat", stageAll ? "HEAD" : "--cached"])
|
||||
).match(/\d+/gm) || []
|
||||
).reduce((partialSum, num) => partialSum + Number(num), 0);
|
||||
|
||||
if (changedLines > 250 && !sudo) {
|
||||
const proceedCommitting = await confirm({
|
||||
message:
|
||||
"You are about to commit changes to more than 250 lines, are you sure you want to proceed?",
|
||||
initialValue: false,
|
||||
});
|
||||
if (changedLines > 250 && !sudo) {
|
||||
const proceedCommitting = await confirm({
|
||||
message:
|
||||
"You are about to commit changes to more than 250 lines, are you sure you want to proceed?",
|
||||
initialValue: false,
|
||||
});
|
||||
|
||||
if (isCancel(proceedCommitting)) {
|
||||
cancel("Commit creation cancelled");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (!proceedCommitting) {
|
||||
cancel("Cancelled, please split this commit into smaller ones");
|
||||
process.exit(0);
|
||||
if (isCancel(proceedCommitting)) {
|
||||
cancel("Commit creation cancelled");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (!proceedCommitting) {
|
||||
cancel("Cancelled, please split this commit into smaller ones");
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
note("HEAD hasn't been found, skipping commit line amount check");
|
||||
}
|
||||
|
||||
const type: string | symbol = await select({
|
||||
|
||||
Reference in New Issue
Block a user