opencommit 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/cli.cjs +20 -12
- package/package.json +1 -1
package/out/cli.cjs
CHANGED
|
@@ -15412,7 +15412,7 @@ function G3(t, e2) {
|
|
|
15412
15412
|
// package.json
|
|
15413
15413
|
var package_default = {
|
|
15414
15414
|
name: "opencommit",
|
|
15415
|
-
version: "1.0.
|
|
15415
|
+
version: "1.0.3",
|
|
15416
15416
|
description: "AI generates conventional commits with mind-blowing accuracy.",
|
|
15417
15417
|
keywords: [
|
|
15418
15418
|
"git",
|
|
@@ -17441,12 +17441,16 @@ var generateCommitMessageWithChatCompletion = async (diff) => {
|
|
|
17441
17441
|
}
|
|
17442
17442
|
};
|
|
17443
17443
|
function getMessagesPromisesByLines(fileDiff, separator) {
|
|
17444
|
-
const
|
|
17445
|
-
const
|
|
17446
|
-
|
|
17444
|
+
const lineSeparator = "\n@@";
|
|
17445
|
+
const [fileHeader, ...fileDiffByLines] = fileDiff.split(lineSeparator);
|
|
17446
|
+
const mergedLines = mergeStrings(
|
|
17447
|
+
fileDiffByLines.map((line) => lineSeparator + line),
|
|
17448
|
+
MAX_REQ_TOKENS
|
|
17447
17449
|
);
|
|
17448
|
-
const
|
|
17449
|
-
|
|
17450
|
+
const lineDiffsWithHeader = mergedLines.map(
|
|
17451
|
+
(d6) => fileHeader + lineSeparator + d6
|
|
17452
|
+
);
|
|
17453
|
+
const commitMsgsFromFileLineDiffs = lineDiffsWithHeader.map((d6) => {
|
|
17450
17454
|
const messages = generateCommitMessageChatCompletionPrompt(separator + d6);
|
|
17451
17455
|
return api.generateCommitMessage(messages);
|
|
17452
17456
|
});
|
|
@@ -17455,9 +17459,9 @@ function getMessagesPromisesByLines(fileDiff, separator) {
|
|
|
17455
17459
|
function getCommitMsgsPromisesFromFileDiffs(diff) {
|
|
17456
17460
|
const separator = "diff --git ";
|
|
17457
17461
|
const diffByFiles = diff.split(separator).slice(1);
|
|
17458
|
-
const
|
|
17462
|
+
const mergedFilesDiffs = mergeStrings(diffByFiles, MAX_REQ_TOKENS);
|
|
17459
17463
|
const commitMessagePromises = [];
|
|
17460
|
-
for (const fileDiff of
|
|
17464
|
+
for (const fileDiff of mergedFilesDiffs) {
|
|
17461
17465
|
if (fileDiff.length >= MAX_REQ_TOKENS) {
|
|
17462
17466
|
const messagesPromises = getMessagesPromisesByLines(fileDiff, separator);
|
|
17463
17467
|
commitMessagePromises.push(...messagesPromises);
|
|
@@ -17497,8 +17501,11 @@ var prepareCommitMessageHook = async () => {
|
|
|
17497
17501
|
);
|
|
17498
17502
|
if (typeof commitMessage !== "string")
|
|
17499
17503
|
throw new Error(commitMessage.error);
|
|
17500
|
-
await import_promises2.default.
|
|
17501
|
-
|
|
17504
|
+
const fileContent = await import_promises2.default.readFile(messageFilePath);
|
|
17505
|
+
await import_promises2.default.writeFile(
|
|
17506
|
+
messageFilePath,
|
|
17507
|
+
commitMessage + "\n" + fileContent.toString()
|
|
17508
|
+
);
|
|
17502
17509
|
} catch (error) {
|
|
17503
17510
|
ce(`${source_default.red("\u2716")} ${error}`);
|
|
17504
17511
|
process.exit(1);
|
|
@@ -17531,8 +17538,9 @@ ${source_default.grey("\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2
|
|
|
17531
17538
|
message: "Confirm the commit message"
|
|
17532
17539
|
});
|
|
17533
17540
|
if (isCommitConfirmedByUser && !C3(isCommitConfirmedByUser)) {
|
|
17534
|
-
await execa("git", ["commit", "-m", commitMessage]);
|
|
17541
|
+
const { stdout } = await execa("git", ["commit", "-m", commitMessage]);
|
|
17535
17542
|
ce(`${source_default.green("\u2714")} successfully committed`);
|
|
17543
|
+
ce(stdout);
|
|
17536
17544
|
} else
|
|
17537
17545
|
ce(`${source_default.gray("\u2716")} process cancelled`);
|
|
17538
17546
|
};
|
|
@@ -17553,7 +17561,7 @@ async function commit(isStageAllFlag = false) {
|
|
|
17553
17561
|
ce(
|
|
17554
17562
|
`${source_default.red("Nothing to commit")} \u2014 stage the files ${source_default.hex("0000FF").bold("`git add .`")} and rerun ${source_default.hex("0000FF").bold("`oc`")} command.`
|
|
17555
17563
|
);
|
|
17556
|
-
stagedFilesSpinner.stop("
|
|
17564
|
+
stagedFilesSpinner.stop("No files are staged");
|
|
17557
17565
|
const isStageAllAndCommitConfirmedByUser = await Q2({
|
|
17558
17566
|
message: "Do you want to stage all files and generate commit message?"
|
|
17559
17567
|
});
|