Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for commit prefix #160

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
build
  • Loading branch information
amitayk committed May 27, 2023
commit 502101797b9a2e579a7a845fe84f30de721c678a
34 changes: 30 additions & 4 deletions out/cli.cjs
Original file line number Diff line number Diff line change
@@ -17684,8 +17684,8 @@ var configValidators = {
["OCO_PREFIX" /* OCO_PREFIX */](value) {
validateConfig(
"OCO_PREFIX" /* OCO_PREFIX */,
true,
"Cannot be empty"
validatePrefix(value),
"Invalid Prefix"
);
return value;
}
@@ -17699,7 +17699,8 @@ var getConfig = () => {
OCO_DESCRIPTION: process.env.OCO_DESCRIPTION === "true" ? true : false,
OCO_EMOJI: process.env.OCO_EMOJI === "true" ? true : false,
OCO_MODEL: process.env.OCO_MODEL || "gpt-3.5-turbo",
OCO_LANGUAGE: process.env.OCO_LANGUAGE || "en"
OCO_LANGUAGE: process.env.OCO_LANGUAGE || "en",
OCO_PREFIX: process.env.OCO_PREFEIX || ""
};
const configExists = (0, import_fs.existsSync)(configPath);
if (!configExists)
@@ -17776,6 +17777,31 @@ var configCommand = G3(
}
}
);
function validatePrefix(prefix) {
if (typeof prefix !== "string") {
ce("Prefix is not a string.");
return false;
}
const isTryingToBeRegex = prefix.match(/^\/.*\/.*|^\^(\(.*\))$/);
if (!isTryingToBeRegex) {
return true;
}
if (!isRegex(prefix)) {
ce("This Regex format is not supported, please use the classic /*/ foramt");
return false;
}
return true;
}
function isRegex(str) {
try {
new RegExp(str);
} catch (e2) {
if (e2 instanceof SyntaxError) {
return false;
}
}
return true;
}

// src/commands/githook.ts
var import_promises = __toESM(require("fs/promises"), 1);
@@ -21826,7 +21852,7 @@ function generatePrefix() {
if (prefix === void 0) {
return void 0;
}
const prefixIsRegexString = prefix.startsWith("/") && prefix.endsWith("/");
const prefixIsRegexString = prefix.match(/\/.*\/*/);
if (prefixIsRegexString) {
try {
return generatePrefixFromRegex(prefix);
Loading
Oops, something went wrong.