git-aicommit 5.1.0 → 5.2.0
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/autocommit.js +8 -5
- package/config.js +0 -1
- package/package.json +1 -1
package/autocommit.js
CHANGED
|
@@ -40,8 +40,9 @@ if (!config.openAiKey && !config.azureOpenAiKey) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// if any settings related to AZURE are set, if there are items that are not set, will error.
|
|
43
|
-
if (
|
|
44
|
-
|
|
43
|
+
if (config.azureOpenAiKey && !(
|
|
44
|
+
config.azureOpenAiInstanceName && config.azureOpenAiDeploymentName && config.azureOpenAiVersion
|
|
45
|
+
)){
|
|
45
46
|
console.error("Please set AZURE_OPENAI_API_KEY, AZURE_OPENAI_API_INSTANCE_NAME, AZURE_OPENAI_API_DEPLOYMENT_NAME, AZURE_OPENAI_API_VERSION when Azure OpenAI Service.");
|
|
46
47
|
process.exit(1);
|
|
47
48
|
}
|
|
@@ -51,9 +52,9 @@ const diffFilter = config.diffFilter || 'ACMRTUXB';
|
|
|
51
52
|
const diffCommand = `git diff --staged \
|
|
52
53
|
--no-ext-diff \
|
|
53
54
|
--diff-filter=${diffFilter} \
|
|
54
|
-
--
|
|
55
|
-
(pattern) =>
|
|
56
|
-
).join(' ')}
|
|
55
|
+
-- ${excludeFromDiff.map(
|
|
56
|
+
(pattern) => `':(exclude)${pattern}'`
|
|
57
|
+
).join(' ')}
|
|
57
58
|
`;
|
|
58
59
|
|
|
59
60
|
let diff = execSync(diffCommand, {encoding: 'utf8'});
|
|
@@ -88,6 +89,7 @@ const chatPrompt = ChatPromptTemplate.fromPromptMessages([
|
|
|
88
89
|
]);
|
|
89
90
|
|
|
90
91
|
if (diff.length > 2000) {
|
|
92
|
+
console.log('Diff is too long. Splitting into multiple requests.')
|
|
91
93
|
const filenameRegex = /^a\/(.+?)\s+b\/(.+?)/;
|
|
92
94
|
const diffByFiles = diff
|
|
93
95
|
.split('diff ' + '--git ') // Wierd string concat in order to avoid splitting on this line when using autocommit in this repo :)
|
|
@@ -106,6 +108,7 @@ if (diff.length > 2000) {
|
|
|
106
108
|
language: config.language,
|
|
107
109
|
})
|
|
108
110
|
.then((prompt) => {
|
|
111
|
+
console.log(prompt)
|
|
109
112
|
return openai.call(prompt)
|
|
110
113
|
.then((res) => {
|
|
111
114
|
return {
|
package/config.js
CHANGED
|
@@ -4,7 +4,6 @@ export default {
|
|
|
4
4
|
azureOpenAiInstanceName: process.env.AZURE_OPENAI_API_INSTANCE_NAME,
|
|
5
5
|
azureOpenAiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME,
|
|
6
6
|
azureOpenAiVersion: process.env.AZURE_OPENAI_API_VERSION,
|
|
7
|
-
addAllChangesBeforeCommit: true,
|
|
8
7
|
autocommit: true,
|
|
9
8
|
openCommitTextEditor: false,
|
|
10
9
|
language: 'english',
|