From 57c6f60d3dfd2091925091620e47e06cae85da34 Mon Sep 17 00:00:00 2001 From: evandeininger Date: Tue, 28 Mar 2023 17:45:41 +0000 Subject: [PATCH 1/4] docs(CONTRIBUTING.md): add step 4 to add api key with `npm run dev -- config set OPENAI_API_KEY=''` --- .github/CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 51fba40f..bb381620 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -9,7 +9,7 @@ Thanks for considering contributing to the project. 3. Create a new branch for your changes. 4. Make your changes and commit them with descriptive commit messages. 5. Push your changes to your forked repository. -6. Create a pull request from your branch to the `dev` branch. +6. Create a pull request from your branch to the `master` branch. ## Getting started @@ -18,7 +18,8 @@ To get started, follow these steps: 1. Clone the project repository locally. 2. Install dependencies with `npm install`. 3. Run the project with `npm run dev`. -4. See [issues](https://github.com/di-sukharev/open-commit/issues) or [TODO.md](../TODO.md) to help the project. +4. Add your api key with `npm run dev -- config set OPENAI_API_KEY=''` +5. See [issues](https://github.com/di-sukharev/open-commit/issues) or [TODO.md](../TODO.md) to help the project. ## Commit message guidelines From b34da99d8a338ee8e5c38432380de64bc14934e5 Mon Sep 17 00:00:00 2001 From: evandeininger Date: Tue, 28 Mar 2023 17:46:18 +0000 Subject: [PATCH 2/4] feat(commit.ts): add support for gitpush config option feat(config.ts): add gitpush config option and validator --- src/commands/commit.ts | 6 ++++++ src/commands/config.ts | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/commands/commit.ts b/src/commands/commit.ts index b16ff95f..f7d003b4 100644 --- a/src/commands/commit.ts +++ b/src/commands/commit.ts @@ -21,6 +21,7 @@ import { } from '@clack/prompts'; import chalk from 'chalk'; import { trytm } from '../utils/trytm'; +import { getConfig } from './config'; // Adding a function to get the list of remotes const getGitRemotes = async () => { @@ -28,6 +29,8 @@ const getGitRemotes = async () => { return stdout.split('\n').filter((remote) => remote.trim() !== ''); }; +const config = getConfig(); + const generateCommitMessageFromGitDiff = async ( diff: string, extraArgs: string[] @@ -79,6 +82,9 @@ ${chalk.grey('——————————————————')}` outro(stdout); const remotes = await getGitRemotes(); + // user isn't pushing, return early + if(config?.gitpush === false) return + if (remotes.length === 1) { const isPushConfirmedByUser = await confirm({ message: 'Do you want to run `git push`?' diff --git a/src/commands/config.ts b/src/commands/config.ts index c10ed41a..5572965c 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -12,7 +12,8 @@ export enum CONFIG_KEYS { OPENAI_API_KEY = 'OPENAI_API_KEY', description = 'description', emoji = 'emoji', - language = 'language' + language = 'language', + gitpush = 'gitpush' } export enum CONFIG_MODES { @@ -70,7 +71,14 @@ export const configValidators = { return value; }, - + [CONFIG_KEYS.gitpush](value: any) { + validateConfig( + CONFIG_KEYS.gitpush, + typeof value === 'boolean', + 'Must be true or false' + ); + return value; + }, [CONFIG_KEYS.language](value: any) { validateConfig( CONFIG_KEYS.language, From e2de6ec5d90b923836e47fb1d75461155ca95a11 Mon Sep 17 00:00:00 2001 From: evandeininger Date: Tue, 28 Mar 2023 17:54:13 +0000 Subject: [PATCH 3/4] docs(README.md): add instructions for turning off git push feature using oc config set gitpush=false command --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 73d6d1c0..5da82678 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,13 @@ oc config set language=française The default language set is **English** All available languages are currently listed in the [i18n](https://github.com/di-sukharev/opencommit/tree/master/src/i18n) folder +### Push to git + +Pushing to git is on by default but if you would like to turn it off just use: +```sh +oc config set gitpush=false +``` + ### Git flags The `opencommit` or `oc` commands can be used in place of the `git commit -m "${generatedMessage}"` command. This means that any regular flags that are used with the `git commit` command will also be applied when using `opencommit` or `oc`. From da363c5e51f37beddf5d2bc6d7d396b62035ebe9 Mon Sep 17 00:00:00 2001 From: evandeininger Date: Tue, 28 Mar 2023 11:37:01 -0700 Subject: [PATCH 4/4] Update .github/CONTRIBUTING.md --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index bb381620..08698671 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -9,7 +9,7 @@ Thanks for considering contributing to the project. 3. Create a new branch for your changes. 4. Make your changes and commit them with descriptive commit messages. 5. Push your changes to your forked repository. -6. Create a pull request from your branch to the `master` branch. +6. Create a pull request from your branch to the `dev` branch. ## Getting started