format files
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
import { execa } from 'execa';
|
import { execa } from 'execa';
|
||||||
import {
|
import { generateCommitMessageByDiff } from '../generateCommitMessageFromGitDiff';
|
||||||
generateCommitMessageByDiff
|
|
||||||
} from '../generateCommitMessageFromGitDiff';
|
|
||||||
import {
|
import {
|
||||||
assertGitRepo,
|
assertGitRepo,
|
||||||
getChangedFiles,
|
getChangedFiles,
|
||||||
@@ -18,9 +16,7 @@ import {
|
|||||||
multiselect,
|
multiselect,
|
||||||
select
|
select
|
||||||
} from '@clack/prompts';
|
} from '@clack/prompts';
|
||||||
import {
|
import { getConfig } from '../commands/config';
|
||||||
getConfig
|
|
||||||
} from '../commands/config';
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { trytm } from '../utils/trytm';
|
import { trytm } from '../utils/trytm';
|
||||||
|
|
||||||
@@ -34,7 +30,8 @@ const getGitRemotes = async () => {
|
|||||||
// Check for the presence of message templates
|
// Check for the presence of message templates
|
||||||
const checkMessageTemplate = (extraArgs: string[]): string | false => {
|
const checkMessageTemplate = (extraArgs: string[]): string | false => {
|
||||||
for (const key in extraArgs) {
|
for (const key in extraArgs) {
|
||||||
if(extraArgs[key].includes(config?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER)) return extraArgs[key];
|
if (extraArgs[key].includes(config?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER))
|
||||||
|
return extraArgs[key];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -52,7 +49,10 @@ const generateCommitMessageFromGitDiff = async (
|
|||||||
let commitMessage = await generateCommitMessageByDiff(diff);
|
let commitMessage = await generateCommitMessageByDiff(diff);
|
||||||
|
|
||||||
if (typeof messageTemplate === 'string') {
|
if (typeof messageTemplate === 'string') {
|
||||||
commitMessage = messageTemplate.replace(config?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER, commitMessage);
|
commitMessage = messageTemplate.replace(
|
||||||
|
config?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
|
||||||
|
commitMessage
|
||||||
|
);
|
||||||
}
|
}
|
||||||
commitSpinner.stop('📝 Commit message generated');
|
commitSpinner.stop('📝 Commit message generated');
|
||||||
|
|
||||||
|
|||||||
@@ -84,10 +84,11 @@ export const generateCommitMessageByDiff = async (
|
|||||||
diff: string
|
diff: string
|
||||||
): Promise<string> => {
|
): Promise<string> => {
|
||||||
try {
|
try {
|
||||||
const MAX_REQUEST_TOKENS = DEFAULT_MODEL_TOKEN_LIMIT
|
const MAX_REQUEST_TOKENS =
|
||||||
- ADJUSTMENT_FACTOR
|
DEFAULT_MODEL_TOKEN_LIMIT -
|
||||||
- INIT_MESSAGES_PROMPT_LENGTH
|
ADJUSTMENT_FACTOR -
|
||||||
- config?.OCO_OPENAI_MAX_TOKENS;
|
INIT_MESSAGES_PROMPT_LENGTH -
|
||||||
|
config?.OCO_OPENAI_MAX_TOKENS;
|
||||||
|
|
||||||
if (tokenCount(diff) >= MAX_REQUEST_TOKENS) {
|
if (tokenCount(diff) >= MAX_REQUEST_TOKENS) {
|
||||||
const commitMessagePromises = getCommitMsgsPromisesFromFileDiffs(
|
const commitMessagePromises = getCommitMsgsPromisesFromFileDiffs(
|
||||||
@@ -154,7 +155,6 @@ function getMessagesPromisesByChangesInFile(
|
|||||||
return commitMsgsFromFileLineDiffs;
|
return commitMsgsFromFileLineDiffs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function splitDiff(diff: string, maxChangeLength: number) {
|
function splitDiff(diff: string, maxChangeLength: number) {
|
||||||
const lines = diff.split('\n');
|
const lines = diff.split('\n');
|
||||||
const splitDiffs = [];
|
const splitDiffs = [];
|
||||||
@@ -219,10 +219,9 @@ export function getCommitMsgsPromisesFromFileDiffs(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return commitMessagePromises;
|
return commitMessagePromises;
|
||||||
}
|
}
|
||||||
|
|
||||||
function delay(ms: number) {
|
function delay(ms: number) {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ export enum I18nLocals {
|
|||||||
'id_ID' = 'id_ID',
|
'id_ID' = 'id_ID',
|
||||||
'pl' = 'pl',
|
'pl' = 'pl',
|
||||||
'tr' = 'tr',
|
'tr' = 'tr',
|
||||||
'th' = 'th',
|
'th' = 'th'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const i18n = {
|
export const i18n = {
|
||||||
|
|||||||
Reference in New Issue
Block a user