opencommit 1.0.3 → 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 +14 -10
- 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);
|
|
@@ -17502,7 +17506,6 @@ var prepareCommitMessageHook = async () => {
|
|
|
17502
17506
|
messageFilePath,
|
|
17503
17507
|
commitMessage + "\n" + fileContent.toString()
|
|
17504
17508
|
);
|
|
17505
|
-
ce(`${source_default.green("\u2714")} commit done`);
|
|
17506
17509
|
} catch (error) {
|
|
17507
17510
|
ce(`${source_default.red("\u2716")} ${error}`);
|
|
17508
17511
|
process.exit(1);
|
|
@@ -17535,8 +17538,9 @@ ${source_default.grey("\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2
|
|
|
17535
17538
|
message: "Confirm the commit message"
|
|
17536
17539
|
});
|
|
17537
17540
|
if (isCommitConfirmedByUser && !C3(isCommitConfirmedByUser)) {
|
|
17538
|
-
await execa("git", ["commit", "-m", commitMessage]);
|
|
17541
|
+
const { stdout } = await execa("git", ["commit", "-m", commitMessage]);
|
|
17539
17542
|
ce(`${source_default.green("\u2714")} successfully committed`);
|
|
17543
|
+
ce(stdout);
|
|
17540
17544
|
} else
|
|
17541
17545
|
ce(`${source_default.gray("\u2716")} process cancelled`);
|
|
17542
17546
|
};
|