Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add proxy configuration #423

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
19,425 changes: 19,380 additions & 45 deletions out/cli.cjs

Large diffs are not rendered by default.

19,343 changes: 19,330 additions & 13 deletions out/github-action.cjs

Large diffs are not rendered by default.

96 changes: 85 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "3.2.3",
"version": "3.2.5",
"description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI πŸ€―πŸ”«",
"keywords": [
"git",
@@ -17,11 +17,11 @@
],
"main": "cli.js",
"bin": {
"opencommit": "./out/cli.cjs",
"oco": "./out/cli.cjs"
"opencommit": "out/cli.cjs",
"oco": "out/cli.cjs"
},
"repository": {
"url": "https://github.com/di-sukharev/opencommit"
"url": "git+https://github.com/di-sukharev/opencommit.git"
},
"type": "module",
"author": "https://github.com/di-sukharev",
@@ -58,7 +58,8 @@
"test:unit:docker": "npm run test:docker-build && DOCKER_CONTENT_TRUST=0 docker run --rm oco-test npm run test:unit",
"test:e2e": "npm run test:e2e:setup && jest test/e2e",
"test:e2e:setup": "sh test/e2e/setup.sh",
"test:e2e:docker": "npm run test:docker-build && DOCKER_CONTENT_TRUST=0 docker run --rm oco-test npm run test:e2e"
"test:e2e:docker": "npm run test:docker-build && DOCKER_CONTENT_TRUST=0 docker run --rm oco-test npm run test:e2e",
"mlx:start": "OCO_AI_PROVIDER='mlx' node ./out/cli.cjs"
},
"devDependencies": {
"@commitlint/types": "^17.4.4",
@@ -87,6 +88,7 @@
"@clack/prompts": "^0.6.1",
"@dqbd/tiktoken": "^1.0.2",
"@google/generative-ai": "^0.11.4",
"@mistralai/mistralai": "^1.3.5",
"@octokit/webhooks-schemas": "^6.11.0",
"@octokit/webhooks-types": "^6.11.0",
"axios": "^1.3.4",
@@ -100,6 +102,8 @@
"ignore": "^5.2.4",
"ini": "^3.0.1",
"inquirer": "^9.1.4",
"openai": "^4.57.0"
"openai": "^4.57.0",
"punycode": "^2.3.1",
"zod": "^3.23.8"
}
}
8 changes: 7 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,12 @@ cli(
commands: [configCommand, hookCommand, commitlintConfigCommand],
flags: {
fgm: Boolean,
context: {
type: String,
alias: 'c',
description: 'Additional user input context for the commit message',
default: ''
},
yes: {
type: Boolean,
alias: 'y',
@@ -37,7 +43,7 @@ cli(
if (await isHookCalled()) {
prepareCommitMessageHook();
} else {
commit(extraArgs, false, flags.fgm, flags.yes);
commit(extraArgs, flags.context, false, flags.fgm, flags.yes);
}
},
extraArgs
45 changes: 26 additions & 19 deletions src/commands/commit.ts
Original file line number Diff line number Diff line change
@@ -39,13 +39,15 @@ const checkMessageTemplate = (extraArgs: string[]): string | false => {
interface GenerateCommitMessageFromGitDiffParams {
diff: string;
extraArgs: string[];
context?: string;
fullGitMojiSpec?: boolean;
skipCommitConfirmation?: boolean;
}

const generateCommitMessageFromGitDiff = async ({
diff,
extraArgs,
context = '',
fullGitMojiSpec = false,
skipCommitConfirmation = false
}: GenerateCommitMessageFromGitDiffParams): Promise<void> => {
@@ -56,7 +58,8 @@ const generateCommitMessageFromGitDiff = async ({
try {
let commitMessage = await generateCommitMessageByDiff(
diff,
fullGitMojiSpec
fullGitMojiSpec,
context
);

const messageTemplate = checkMessageTemplate(extraArgs);
@@ -135,8 +138,7 @@ ${chalk.grey('β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”')}`
]);

pushSpinner.stop(
`${chalk.green('βœ”')} Successfully pushed all commits to ${
remotes[0]
`${chalk.green('βœ”')} Successfully pushed all commits to ${remotes[0]
}`
);

@@ -146,26 +148,29 @@ ${chalk.grey('β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”')}`
process.exit(0);
}
} else {
const skipOption = `don't push`
const selectedRemote = (await select({
message: 'Choose a remote to push to',
options: remotes.map((remote) => ({ value: remote, label: remote }))
options: [...remotes, skipOption].map((remote) => ({ value: remote, label: remote })),
})) as string;

if (isCancel(selectedRemote)) process.exit(1);

const pushSpinner = spinner();

pushSpinner.start(`Running 'git push ${selectedRemote}'`);

const { stdout } = await execa('git', ['push', selectedRemote]);

if (stdout) outro(stdout);

pushSpinner.stop(
`${chalk.green(
'βœ”'
)} successfully pushed all commits to ${selectedRemote}`
);
if (selectedRemote !== skipOption) {
const pushSpinner = spinner();

pushSpinner.start(`Running 'git push ${selectedRemote}'`);

const { stdout } = await execa('git', ['push', selectedRemote]);

if (stdout) outro(stdout);

pushSpinner.stop(
`${chalk.green(
'βœ”'
)} successfully pushed all commits to ${selectedRemote}`
);
}
}
} else {
const regenerateMessage = await confirm({
@@ -197,6 +202,7 @@ ${chalk.grey('β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”')}`

export async function commit(
extraArgs: string[] = [],
context: string = '',
isStageAllFlag: Boolean = false,
fullGitMojiSpec: boolean = false,
skipCommitConfirmation: boolean = false
@@ -238,7 +244,7 @@ export async function commit(
if (isCancel(isStageAllAndCommitConfirmedByUser)) process.exit(1);

if (isStageAllAndCommitConfirmedByUser) {
await commit(extraArgs, true, fullGitMojiSpec);
await commit(extraArgs, context, true, fullGitMojiSpec);
process.exit(1);
}

@@ -256,7 +262,7 @@ export async function commit(
await gitAdd({ files });
}

await commit(extraArgs, false, fullGitMojiSpec);
await commit(extraArgs, context, false, fullGitMojiSpec);
process.exit(1);
}

@@ -270,6 +276,7 @@ export async function commit(
generateCommitMessageFromGitDiff({
diff: await getDiff({ files: stagedFiles }),
extraArgs,
context,
fullGitMojiSpec,
skipCommitConfirmation
})
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.