opencommit 1.1.41 → 1.1.42
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 +15 -31
- package/package.json +1 -1
package/out/cli.cjs
CHANGED
|
@@ -39,17 +39,17 @@ var require_ini = __commonJS({
|
|
|
39
39
|
opt = opt || /* @__PURE__ */ Object.create(null);
|
|
40
40
|
opt.whitespace = opt.whitespace === true;
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const separator = opt.whitespace ? " = " : "=";
|
|
43
43
|
for (const k6 of Object.keys(obj)) {
|
|
44
44
|
const val = obj[k6];
|
|
45
45
|
if (val && Array.isArray(val)) {
|
|
46
46
|
for (const item of val) {
|
|
47
|
-
out += safe(k6 + "[]") +
|
|
47
|
+
out += safe(k6 + "[]") + separator + safe(item) + eol;
|
|
48
48
|
}
|
|
49
49
|
} else if (val && typeof val === "object") {
|
|
50
50
|
children.push(k6);
|
|
51
51
|
} else {
|
|
52
|
-
out += safe(k6) +
|
|
52
|
+
out += safe(k6) + separator + safe(val) + eol;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
if (opt.section && out.length) {
|
|
@@ -539,8 +539,8 @@ var require_path_key = __commonJS({
|
|
|
539
539
|
"use strict";
|
|
540
540
|
var pathKey2 = (options = {}) => {
|
|
541
541
|
const environment = options.env || process.env;
|
|
542
|
-
const
|
|
543
|
-
if (
|
|
542
|
+
const platform = options.platform || process.platform;
|
|
543
|
+
if (platform !== "win32") {
|
|
544
544
|
return "PATH";
|
|
545
545
|
}
|
|
546
546
|
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
@@ -15763,7 +15763,7 @@ function G3(t, e2) {
|
|
|
15763
15763
|
// package.json
|
|
15764
15764
|
var package_default = {
|
|
15765
15765
|
name: "opencommit",
|
|
15766
|
-
version: "1.1.
|
|
15766
|
+
version: "1.1.41",
|
|
15767
15767
|
description: "GPT CLI to auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
|
|
15768
15768
|
keywords: [
|
|
15769
15769
|
"git",
|
|
@@ -17215,9 +17215,9 @@ var import_node_url = __toESM(require("node:url"), 1);
|
|
|
17215
17215
|
function pathKey(options = {}) {
|
|
17216
17216
|
const {
|
|
17217
17217
|
env: env2 = process.env,
|
|
17218
|
-
platform
|
|
17218
|
+
platform = process.platform
|
|
17219
17219
|
} = options;
|
|
17220
|
-
if (
|
|
17220
|
+
if (platform !== "win32") {
|
|
17221
17221
|
return "PATH";
|
|
17222
17222
|
}
|
|
17223
17223
|
return Object.keys(env2).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
@@ -18187,24 +18187,8 @@ ${lockFiles.join(
|
|
|
18187
18187
|
|
|
18188
18188
|
// src/commands/githook.ts
|
|
18189
18189
|
var import_fs3 = require("fs");
|
|
18190
|
-
var platform = process.platform;
|
|
18191
|
-
var separator = "";
|
|
18192
|
-
switch (platform) {
|
|
18193
|
-
case "win32":
|
|
18194
|
-
separator = import_path2.default.sep;
|
|
18195
|
-
break;
|
|
18196
|
-
case "darwin":
|
|
18197
|
-
separator = "";
|
|
18198
|
-
break;
|
|
18199
|
-
case "android":
|
|
18200
|
-
case "linux":
|
|
18201
|
-
separator = "";
|
|
18202
|
-
break;
|
|
18203
|
-
default:
|
|
18204
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
18205
|
-
}
|
|
18206
18190
|
var HOOK_NAME = "prepare-commit-msg";
|
|
18207
|
-
var DEFAULT_SYMLINK_URL = import_path2.default.join(
|
|
18191
|
+
var DEFAULT_SYMLINK_URL = import_path2.default.join(".git", "hooks", HOOK_NAME);
|
|
18208
18192
|
var getHooksPath = async () => {
|
|
18209
18193
|
try {
|
|
18210
18194
|
const hooksPath = await getCoreHooksPath();
|
|
@@ -21257,7 +21241,7 @@ var generateCommitMessageWithChatCompletion = async (diff) => {
|
|
|
21257
21241
|
return { error: "INTERNAL_ERROR" /* internalError */ };
|
|
21258
21242
|
}
|
|
21259
21243
|
};
|
|
21260
|
-
function getMessagesPromisesByChangesInFile(fileDiff,
|
|
21244
|
+
function getMessagesPromisesByChangesInFile(fileDiff, separator, maxChangeLength) {
|
|
21261
21245
|
const hunkHeaderSeparator = "@@ ";
|
|
21262
21246
|
const [fileHeader, ...fileDiffByLines] = fileDiff.split(hunkHeaderSeparator);
|
|
21263
21247
|
const mergedChanges = mergeDiffs(
|
|
@@ -21269,28 +21253,28 @@ function getMessagesPromisesByChangesInFile(fileDiff, separator2, maxChangeLengt
|
|
|
21269
21253
|
);
|
|
21270
21254
|
const commitMsgsFromFileLineDiffs = lineDiffsWithHeader.map((lineDiff) => {
|
|
21271
21255
|
const messages = generateCommitMessageChatCompletionPrompt(
|
|
21272
|
-
|
|
21256
|
+
separator + lineDiff
|
|
21273
21257
|
);
|
|
21274
21258
|
return api.generateCommitMessage(messages);
|
|
21275
21259
|
});
|
|
21276
21260
|
return commitMsgsFromFileLineDiffs;
|
|
21277
21261
|
}
|
|
21278
21262
|
function getCommitMsgsPromisesFromFileDiffs(diff, maxDiffLength) {
|
|
21279
|
-
const
|
|
21280
|
-
const diffByFiles = diff.split(
|
|
21263
|
+
const separator = "diff --git ";
|
|
21264
|
+
const diffByFiles = diff.split(separator).slice(1);
|
|
21281
21265
|
const mergedFilesDiffs = mergeDiffs(diffByFiles, maxDiffLength);
|
|
21282
21266
|
const commitMessagePromises = [];
|
|
21283
21267
|
for (const fileDiff of mergedFilesDiffs) {
|
|
21284
21268
|
if (tokenCount(fileDiff) >= maxDiffLength) {
|
|
21285
21269
|
const messagesPromises = getMessagesPromisesByChangesInFile(
|
|
21286
21270
|
fileDiff,
|
|
21287
|
-
|
|
21271
|
+
separator,
|
|
21288
21272
|
maxDiffLength
|
|
21289
21273
|
);
|
|
21290
21274
|
commitMessagePromises.push(...messagesPromises);
|
|
21291
21275
|
} else {
|
|
21292
21276
|
const messages = generateCommitMessageChatCompletionPrompt(
|
|
21293
|
-
|
|
21277
|
+
separator + fileDiff
|
|
21294
21278
|
);
|
|
21295
21279
|
commitMessagePromises.push(api.generateCommitMessage(messages));
|
|
21296
21280
|
}
|