mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-10 22:28:14 -05:00
build
This commit is contained in:
@@ -57,11 +57,12 @@ jobs:
|
||||
- uses: di-sukharev/opencommit@github-action
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
OCO_OPENAI_API_KEY: ${{ secrets.OCO_OPENAI_API_KEY }}
|
||||
|
||||
env:
|
||||
# only improve messages that match the regexp, e.g. ^fix$
|
||||
pattern: ''
|
||||
# set openAI api key in repo actions secrets,
|
||||
# for openAI keys go to: https://platform.openai.com/account/api-keys
|
||||
# for repo secret go to: <your_repo_url>/settings/secrets/actions
|
||||
OCO_OPENAI_API_KEY: ${{ secrets.OCO_OPENAI_API_KEY }}
|
||||
|
||||
# customization
|
||||
OCO_OPENAI_MAX_TOKENS: 500
|
||||
@@ -69,7 +70,7 @@ jobs:
|
||||
OCO_DESCRIPTION: false
|
||||
OCO_EMOJI: false
|
||||
OCO_MODEL: gpt-3.5-turbo
|
||||
OCO_LANGUAGE: De
|
||||
OCO_LANGUAGE: en
|
||||
```
|
||||
|
||||
That is it. Now when you push to any branch in your repo — all NEW commits are being improved by never-tired-AI.
|
||||
|
||||
18
out/cli.cjs
18
out/cli.cjs
@@ -17679,28 +17679,20 @@ var configValidators = {
|
||||
`${value} is not supported yet, use 'gpt-4' or 'gpt-3.5-turbo' (default)`
|
||||
);
|
||||
return value;
|
||||
},
|
||||
["OCO_EXCLUDE" /* OCO_EXCLUDE */](value) {
|
||||
validateConfig(
|
||||
"OCO_EXCLUDE" /* OCO_EXCLUDE */,
|
||||
typeof value === "string",
|
||||
`${value} is not a valid regexp`
|
||||
);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
var configPath = (0, import_path.join)((0, import_os.homedir)(), ".opencommit");
|
||||
var getConfig = () => {
|
||||
const configFromEnv = {
|
||||
OCO_OPENAI_API_KEY: process.env.OCO_OPENAI_API_KEY,
|
||||
OCO_OPENAI_MAX_TOKENS: process.env.OCO_OPENAI_MAX_TOKENS,
|
||||
OCO_OPENAI_MAX_TOKENS: Number(process.env.OCO_OPENAI_MAX_TOKENS),
|
||||
OCO_OPENAI_BASE_PATH: process.env.OCO_OPENAI_BASE_PATH,
|
||||
OCO_DESCRIPTION: process.env.OCO_DESCRIPTION,
|
||||
OCO_EMOJI: process.env.OCO_EMOJI,
|
||||
OCO_DESCRIPTION: Boolean(process.env.OCO_DESCRIPTION),
|
||||
OCO_EMOJI: Boolean(process.env.OCO_EMOJI),
|
||||
OCO_MODEL: process.env.OCO_MODEL,
|
||||
OCO_LANGUAGE: process.env.OCO_LANGUAGE,
|
||||
OCO_EXCLUDE: process.env.OCO_EXCLUDE
|
||||
OCO_LANGUAGE: process.env.OCO_LANGUAGE
|
||||
};
|
||||
console.log({ configFromEnv });
|
||||
const configExists = (0, import_fs.existsSync)(configPath);
|
||||
if (!configExists)
|
||||
return configFromEnv;
|
||||
|
||||
@@ -23227,8 +23227,8 @@ var isBlob = kindOfTest("Blob");
|
||||
var isFileList = kindOfTest("FileList");
|
||||
var isStream = (val) => isObject(val) && isFunction(val.pipe);
|
||||
var isFormData = (thing) => {
|
||||
const pattern2 = "[object FormData]";
|
||||
return thing && (typeof FormData === "function" && thing instanceof FormData || toString.call(thing) === pattern2 || isFunction(thing.toString) && thing.toString() === pattern2);
|
||||
const pattern = "[object FormData]";
|
||||
return thing && (typeof FormData === "function" && thing instanceof FormData || toString.call(thing) === pattern || isFunction(thing.toString) && thing.toString() === pattern);
|
||||
};
|
||||
var isURLSearchParams = kindOfTest("URLSearchParams");
|
||||
var trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
||||
@@ -26875,28 +26875,20 @@ var configValidators = {
|
||||
`${value} is not supported yet, use 'gpt-4' or 'gpt-3.5-turbo' (default)`
|
||||
);
|
||||
return value;
|
||||
},
|
||||
["OCO_EXCLUDE" /* OCO_EXCLUDE */](value) {
|
||||
validateConfig(
|
||||
"OCO_EXCLUDE" /* OCO_EXCLUDE */,
|
||||
typeof value === "string",
|
||||
`${value} is not a valid regexp`
|
||||
);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
var configPath = (0, import_path.join)((0, import_os.homedir)(), ".opencommit");
|
||||
var getConfig = () => {
|
||||
const configFromEnv = {
|
||||
OCO_OPENAI_API_KEY: process.env.OCO_OPENAI_API_KEY,
|
||||
OCO_OPENAI_MAX_TOKENS: process.env.OCO_OPENAI_MAX_TOKENS,
|
||||
OCO_OPENAI_MAX_TOKENS: Number(process.env.OCO_OPENAI_MAX_TOKENS),
|
||||
OCO_OPENAI_BASE_PATH: process.env.OCO_OPENAI_BASE_PATH,
|
||||
OCO_DESCRIPTION: process.env.OCO_DESCRIPTION,
|
||||
OCO_EMOJI: process.env.OCO_EMOJI,
|
||||
OCO_DESCRIPTION: Boolean(process.env.OCO_DESCRIPTION),
|
||||
OCO_EMOJI: Boolean(process.env.OCO_EMOJI),
|
||||
OCO_MODEL: process.env.OCO_MODEL,
|
||||
OCO_LANGUAGE: process.env.OCO_LANGUAGE,
|
||||
OCO_EXCLUDE: process.env.OCO_EXCLUDE
|
||||
OCO_LANGUAGE: process.env.OCO_LANGUAGE
|
||||
};
|
||||
console.log({ configFromEnv });
|
||||
const configExists = (0, import_fs.existsSync)(configPath);
|
||||
if (!configExists)
|
||||
return configFromEnv;
|
||||
@@ -27192,7 +27184,6 @@ function randomIntFromInterval(min, max) {
|
||||
// src/github-action.ts
|
||||
var import_fs2 = require("fs");
|
||||
var GITHUB_TOKEN = import_core3.default.getInput("GITHUB_TOKEN");
|
||||
var pattern = import_core3.default.getInput("pattern");
|
||||
var octokit = import_github.default.getOctokit(GITHUB_TOKEN);
|
||||
var context = import_github.default.context;
|
||||
var owner = context.repo.owner;
|
||||
@@ -27253,8 +27244,7 @@ var getDiffsBySHAs = async (SHAs) => {
|
||||
});
|
||||
return diffs;
|
||||
};
|
||||
async function improveCommitMessages(commits) {
|
||||
let commitsToImprove = pattern ? commits.filter((commit) => new RegExp(pattern).test(commit.message)) : commits;
|
||||
async function improveCommitMessages(commitsToImprove) {
|
||||
if (commitsToImprove.length) {
|
||||
ce(`Found ${commitsToImprove.length} commits to improve.`);
|
||||
} else {
|
||||
|
||||
@@ -19,8 +19,7 @@ export enum CONFIG_KEYS {
|
||||
OCO_DESCRIPTION = 'OCO_DESCRIPTION',
|
||||
OCO_EMOJI = 'OCO_EMOJI',
|
||||
OCO_MODEL = 'OCO_MODEL',
|
||||
OCO_LANGUAGE = 'OCO_LANGUAGE',
|
||||
OCO_EXCLUDE = 'OCO_EXCLUDE'
|
||||
OCO_LANGUAGE = 'OCO_LANGUAGE'
|
||||
}
|
||||
|
||||
export enum CONFIG_MODES {
|
||||
@@ -123,15 +122,6 @@ export const configValidators = {
|
||||
`${value} is not supported yet, use 'gpt-4' or 'gpt-3.5-turbo' (default)`
|
||||
);
|
||||
return value;
|
||||
},
|
||||
|
||||
[CONFIG_KEYS.OCO_EXCLUDE](value: any) {
|
||||
validateConfig(
|
||||
CONFIG_KEYS.OCO_EXCLUDE,
|
||||
typeof value === 'string',
|
||||
`${value} is not a valid regexp`
|
||||
);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -144,15 +134,16 @@ const configPath = pathJoin(homedir(), '.opencommit');
|
||||
export const getConfig = (): ConfigType | null => {
|
||||
const configFromEnv = {
|
||||
OCO_OPENAI_API_KEY: process.env.OCO_OPENAI_API_KEY,
|
||||
OCO_OPENAI_MAX_TOKENS: process.env.OCO_OPENAI_MAX_TOKENS,
|
||||
OCO_OPENAI_MAX_TOKENS: Number(process.env.OCO_OPENAI_MAX_TOKENS),
|
||||
OCO_OPENAI_BASE_PATH: process.env.OCO_OPENAI_BASE_PATH,
|
||||
OCO_DESCRIPTION: process.env.OCO_DESCRIPTION,
|
||||
OCO_EMOJI: process.env.OCO_EMOJI,
|
||||
OCO_DESCRIPTION: Boolean(process.env.OCO_DESCRIPTION),
|
||||
OCO_EMOJI: Boolean(process.env.OCO_EMOJI),
|
||||
OCO_MODEL: process.env.OCO_MODEL,
|
||||
OCO_LANGUAGE: process.env.OCO_LANGUAGE,
|
||||
OCO_EXCLUDE: process.env.OCO_EXCLUDE
|
||||
OCO_LANGUAGE: process.env.OCO_LANGUAGE
|
||||
};
|
||||
|
||||
console.log({ configFromEnv });
|
||||
|
||||
const configExists = existsSync(configPath);
|
||||
if (!configExists) return configFromEnv;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import { unlinkSync, writeFileSync } from 'fs';
|
||||
// GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
// https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token#about-the-github_token-secret
|
||||
const GITHUB_TOKEN = core.getInput('GITHUB_TOKEN');
|
||||
const pattern = core.getInput('pattern');
|
||||
const octokit = github.getOctokit(GITHUB_TOKEN);
|
||||
const context = github.context;
|
||||
const owner = context.repo.owner;
|
||||
@@ -113,12 +112,8 @@ const getDiffsBySHAs = async (SHAs: string[]) => {
|
||||
};
|
||||
|
||||
async function improveCommitMessages(
|
||||
commits: { id: string; message: string }[]
|
||||
commitsToImprove: { id: string; message: string }[]
|
||||
): Promise<void> {
|
||||
let commitsToImprove = pattern
|
||||
? commits.filter((commit) => new RegExp(pattern).test(commit.message))
|
||||
: commits;
|
||||
|
||||
if (commitsToImprove.length) {
|
||||
outro(`Found ${commitsToImprove.length} commits to improve.`);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user