Code Monkey home page Code Monkey logo

opencommit's Introduction

OpenCommit logo

OpenCommit

Follow the bird

Auto-generate meaningful commits in a second

Killing lame commits with AI πŸ€―πŸ”«

Current version

πŸͺ© Winner of GitHub 2023 hackathon πŸͺ©


OpenCommit example

All the commits in this repo are authored by OpenCommit β€” look at the commits to see how OpenCommit works. Emojis and long commit descriptions are configurable.

Setup OpenCommit as a CLI tool

You can use OpenCommit by simply running it via the CLI like this oco. 2 seconds and your staged changes are committed with a meaningful message.

  1. Install OpenCommit globally to use in any repository:

    npm install -g opencommit

    Alternatively run it via npx opencommit or bunx opencommit

    MacOS may ask to run the command with sudo when installing a package globally.

  2. Get your API key from OpenAI. Make sure that you add your payment details, so the API works.

  3. Set the key to OpenCommit config:

    oco config set OCO_OPENAI_API_KEY=<your_api_key>

    Your API key is stored locally in the ~/.opencommit config file.

Usage

You can call OpenCommit directly to generate a commit message for your staged changes:

git add <files...>
opencommit

You can also use the oco shortcut:

git add <files...>
oco

Link to the GitMoji specification: https://gitmoji.dev/

You can also run it with local model through ollama:

  • install and start ollama
  • run ollama run mistral (do this only once, to pull model)
  • run (in your project directory):
git add <files...>
OCO_AI_PROVIDER='ollama' opencommit

Flags

There are multiple optional flags that can be used with the oco command:

Use Full GitMoji Specification

This flag can only be used if the OCO_EMOJI configuration item is set to true. This flag allows users to use all emojis in the GitMoji specification, By default, the GitMoji full specification is set to false, which only includes 10 emojis (πŸ›βœ¨πŸ“πŸš€βœ…β™»οΈβ¬†οΈπŸ”§πŸŒπŸ’‘). This is due to limit the number of tokens sent in each request. However, if you would like to use the full GitMoji specification, you can use the --fgm flag.

oco --fgm

Configuration

Local per repo configuration

Create a .env file and add OpenCommit config variables there like this:

OCO_OPENAI_API_KEY=<your OpenAI API token>
OCO_TOKENS_MAX_INPUT=<max model token limit (default: 4096)>
OCO_TOKENS_MAX_OUTPUT=<max response tokens (default: 500)>
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to OpenAI api>
OCO_DESCRIPTION=<postface a message with ~3 sentences description of the changes>
OCO_EMOJI=<boolean, add GitMoji>
OCO_MODEL=<either 'gpt-4', 'gpt-3.5-turbo' (default), 'gpt-3.5-turbo-0125', 'gpt-4-1106-preview', 'gpt-4-turbo-preview' or 'gpt-4-0125-preview'>
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=<message template placeholder, default: '$msg'>
OCO_PROMPT_MODULE=<either conventional-commit or @commitlint, default: conventional-commit>
OCO_ONE_LINE_COMMIT=<one line commit message, default: false>

Global config for all repos

Local config still has more priority than Global config, but you may set OCO_MODEL and OCO_LOCALE globally and set local configs for OCO_EMOJI and OCO_DESCRIPTION per repo which is more convenient.

Simply set any of the variables above like this:

oco config set OCO_MODEL=gpt-4

Configure GitMoji to preface a message.

oco config set OCO_EMOJI=true

To remove preface emojis:

oco config set OCO_EMOJI=false

Switch to GPT-4 or other models

By default, OpenCommit uses gpt-3.5-turbo model.

You may switch to GPT-4 which performs better, but costs ~x15 times more 🀠

oco config set OCO_MODEL=gpt-4

or for as a cheaper option:

oco config set OCO_MODEL=gpt-3.5-turbo

or for GPT-4 Turbo (Preview) which is more capable, has knowledge of world events up to April 2023, a 128k context window and 2-3x cheaper vs GPT-4:

oco config set OCO_MODEL=gpt-4-0125-preview

Make sure that you spell it gpt-4 (lowercase) and that you have API access to the 4th model. Even if you have ChatGPT+, that doesn't necessarily mean that you have API access to GPT-4.

Locale configuration

To globally specify the language used to generate commit messages:

# de, German ,Deutsch
oco config set OCO_LANGUAGE=de
oco config set OCO_LANGUAGE=German
oco config set OCO_LANGUAGE=Deutsch

# fr, French, française
oco config set OCO_LANGUAGE=fr
oco config set OCO_LANGUAGE=French
oco config set OCO_LANGUAGE=française

The default language setting is English All available languages are currently listed in the i18n folder

Switch to @commitlint

OpenCommit allows you to choose the prompt module used to generate commit messages. By default, OpenCommit uses its conventional-commit message generator. However, you can switch to using the @commitlint prompt module if you prefer. This option lets you generate commit messages in respect with the local config.

You can set this option by running the following command:

oco config set OCO_PROMPT_MODULE=<module>

Replace <module> with either conventional-commit or @commitlint.

Example:

To switch to using th '@commitlint prompt module, run:

oco config set OCO_PROMPT_MODULE=@commitlint

To switch back to the default conventional-commit message generator, run:

oco config set OCO_PROMPT_MODULE=conventional-commit

Integrating with @commitlint

The integration between @commitlint and OpenCommit is done automatically the first time OpenCommit is run with OCO_PROMPT_MODULE set to @commitlint. However, if you need to force set or reset the configuration for @commitlint, you can run the following command:

oco commitlint force

To view the generated configuration for @commitlint, you can use this command:

oco commitlint get

This allows you to ensure that the configuration is set up as desired.

Additionally, the integration creates a file named .opencommit-commitlint which contains the prompts used for the local @commitlint configuration. You can modify this file to fine-tune the example commit message generated by OpenAI. This gives you the flexibility to make adjustments based on your preferences or project guidelines.

OpenCommit generates a file named .opencommit-commitlint in your project directory which contains the prompts used for the local @commitlint configuration. You can modify this file to fine-tune the example commit message generated by OpenAI. If the local @commitlint configuration changes, this file will be updated the next time OpenCommit is run.

This offers you greater control over the generated commit messages, allowing for customization that aligns with your project's conventions.

Git flags

The opencommit or oco 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 oco.

oco --no-verify

is translated to :

git commit -m "${generatedMessage}" --no-verify

To include a message in the generated message, you can utilize the template function, for instance:

oco '#205: $msg’

opencommit examines placeholders in the parameters, allowing you to append additional information before and after the placeholders, such as the relevant Issue or Pull Request. Similarly, you have the option to customize the OCO_MESSAGE_TEMPLATE_PLACEHOLDER configuration item, for example, simplifying it to $m!"

Message Template Placeholder Config

Overview

The OCO_MESSAGE_TEMPLATE_PLACEHOLDER feature in the opencommit tool allows users to embed a custom message within the generated commit message using a template function. This configuration is designed to enhance the flexibility and customizability of commit messages, making it easier for users to include relevant information directly within their commits.

Implementation Details

In our codebase, the implementation of this feature can be found in the following segment:

commitMessage = messageTemplate.replace(
  config?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
  commitMessage
);

This line is responsible for replacing the placeholder in the messageTemplate with the actual commitMessage.

Usage

For instance, using the command oco '$msg #205’, users can leverage this feature. The provided code represents the backend mechanics of such commands, ensuring that the placeholder is replaced with the appropriate commit message.

Committing with the Message

Once users have generated their desired commit message, they can proceed to commit using the generated message. By understanding the feature's full potential and its implementation details, users can confidently use the generated messages for their commits.

Ignore files

You can remove files from being sent to OpenAI by creating a .opencommitignore file. For example:

path/to/large-asset.zip
**/*.jpg

This helps prevent opencommit from uploading artifacts and large files.

By default, opencommit ignores files matching: *-lock.* and *.lock

Git hook (KILLER FEATURE)

You can set OpenCommit as Git prepare-commit-msg hook. Hook integrates with your IDE Source Control and allows you to edit the message before committing.

To set the hook:

oco hook set

To unset the hook:

oco hook unset

To use the hook:

git add <files...>
git commit

Or follow the process of your IDE Source Control feature, when it calls git commit command β€” OpenCommit will integrate into the flow.

Setup OpenCommit as a GitHub Action (BETA) πŸ”₯

OpenCommit is now available as a GitHub Action which automatically improves all new commits messages when you push to remote!

This is great if you want to make sure all of the commits in all of your repository branches are meaningful and not lame like fix1 or done2.

Create a file .github/workflows/opencommit.yml with the contents below:

name: 'OpenCommit Action'

on:
  push:
    # this list of branches is often enough,
    # but you may still ignore other public branches
    branches-ignore: [main master dev development release]

jobs:
  opencommit:
    timeout-minutes: 10
    name: OpenCommit
    runs-on: ubuntu-latest
    permissions: write-all
    steps:
      - name: Setup Node.js Environment
        uses: actions/setup-node@v2
        with:
          node-version: '16'
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: di-sukharev/[email protected]
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

        env:
          # 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_TOKENS_MAX_INPUT: 4096
          OCO_TOKENS_MAX_OUTPUT: 500
          OCO_OPENAI_BASE_PATH: ''
          OCO_DESCRIPTION: false
          OCO_EMOJI: false
          OCO_MODEL: gpt-3.5-turbo
          OCO_LANGUAGE: en
          OCO_PROMPT_MODULE: conventional-commit

That is it. Now when you push to any branch in your repo β€” all NEW commits are being improved by your never-tired AI.

Make sure you exclude public collaboration branches (main, dev, etc) in branches-ignore, so OpenCommit does not rebase commits there while improving the messages.

Interactive rebase (rebase -i) changes commits' SHA, so the commit history in remote becomes different from your local branch history. This is okay if you work on the branch alone, but may be inconvenient for other collaborators.

Payments

You pay for your requests to OpenAI API on your own.

OpenCommit stores your key locally.

OpenCommit by default uses 3.5-turbo model, it should not exceed $0.10 per casual working day.

You may switch to gpt-4, it's better, but more expensive.

opencommit's People

Contributors

adrielbento avatar alexcgomez avatar avighnac avatar bennycode avatar di-sukharev avatar dmazlum avatar ericklima-ca avatar esmerlinjm avatar ewiththebowtie avatar gamoreli avatar imload avatar ingwarsw avatar jaroslaw-weber avatar jeroensmink98 avatar jessicakuijer avatar jlopezlira avatar jlukic avatar joshuahamlet avatar km-tr avatar linhdangquang avatar malpou avatar mathsgod avatar matt-degraffenreid avatar moret84 avatar nader-zouaoui avatar openefit avatar sectex avatar superstructor avatar takuya-o avatar willyw0nka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencommit's Issues

Infinite loop setting the key

  • When adding the openAI token, the code show the same error message.

  • My machine is a macbook pro m2 , running on Ventura 13.12.1

Screenshot 2023-03-10 at 15 50 51

Feature: Support git commit prefixes

Hi, I'm happy to contribute to this. My work requires that the ticket be referenced in all commit messages e.g. foo-1243-feature-button-component. I'm wondering if it is viable to make the commits reference the ticket number from the branch name e.g. feat/foo-1234-button would result in commit messages being prefixed with foo-1234: blah blah?

Suggest adding 'Edit' option to the Yes/No confirmation

The tool did a great job of generating the message. I would have liked to add a note about who suggested the fix.

Also, another time, it got a huge amount right but also got something wrong. I would have liked to fix it without losing the AI contribution. (In that case, I copied the message, said No and did a conventional commit with edited text.)

Bug: Use '--' to separate paths from revisions

image

oc

β”Œ  open-commit
β”‚
β—‡  1 staged files:
  .config/hyprland/hyprland.conf
/home/abc/.node_modules/lib/node_modules/opencommit/out/cli.cjs:17320
    error = new Error(message);
            ^

Error: Command failed with exit code 128: git diff --staged .config/hyprland/hyprland.
conf
fatal: ambiguous argument '.config/hyprland/hyprland.conf': unknown revision or path n
ot in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
    at makeError (/home/abc/.node_modules/lib/node_modules/opencommit/out/cli.cjs:1732
0:13)
    at handlePromise (/home/abc/.node_modules/lib/node_modules/opencommit/out/cli.cjs:
17635:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getDiff (/home/abc/.node_modules/lib/node_modules/opencommit/out/cli.cjs:
17724:28)
    at async commit (/home/abc/.node_modules/lib/node_modules/opencommit/out/cli.cjs:2
0939:38) {
  shortMessage: 'Command failed with exit code 128: git diff --staged .config/hyprland
/hyprland.conf',
  command: 'git diff --staged .config/hyprland/hyprland.conf',
  escapedCommand: 'git diff --staged ".config/hyprland/hyprland.conf"',
  exitCode: 128,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: "fatal: ambiguous argument '.config/hyprland/hyprland.conf': unknown revisio
n or path not in the working tree.\n" +
    "Use '--' to separate paths from revisions, like this:\n" +
    "'git <command> [<revision>...] -- [<file>...]'",
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Node.js v19.8.1

POV

# env
GIT_WORK_TREE=/home/abc
GIT_DIR=/home/abc/dotfiles

press `TAB` to generate new commit message/s

A feature request.

Currently, if we don't like the generated commit message we would select "No" in the confirm prompt then rerun oc to generate a new message.

Would be nice and convenient to just press TAB to generate a new one.

Error after generating commit : ERR_TTY_INIT_FAILED

Config: VS Code on Windows 11

Getting error ERR_TTY_INIT_FAILED when generating commit.

οΏ½[90mβ””οΏ½[39m  Commit message:
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
fix(AppMailUseCase.ts): add notEmpty filter to notifications array in deleteMail method
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

node:internal/errors:477
    ErrorCaptureStackTrace(err);
    ^

SystemError [ERR_TTY_INIT_FAILED]: TTY initialization failed: uv_tty_init returned EBADF (bad file descriptor)
    at new SystemError (node:internal/errors:238:5)
    at new NodeError (node:internal/errors:349:7)
    at new WriteStream (node:tty:94:11)
    at sD2.prompt (C:\Users\svad\AppData\Roaming\npm\node_modules\opencommit\out\cli.cjs:15719:16)
    at Q3 (C:\Users\svad\AppData\Roaming\npm\node_modules\opencommit\out\cli.cjs:15891:8)
    at generateCommitMessageFromGitDiff (C:\Users\svad\AppData\Roaming\npm\node_modules\opencommit\out\cli.cjs:17756:41)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async commit (C:\Users\svad\AppData\Roaming\npm\node_modules\opencommit\out\cli.cjs:17807:3) {
  code: 'ERR_TTY_INIT_FAILED',
  info: {
    errno: -4083,
    code: 'EBADF',
    message: 'bad file descriptor',
    syscall: 'uv_tty_init'
  },
  errno: [Getter/Setter],
  syscall: [Getter/Setter]
}

I have same error when using command oc, or using VS Code commit button with git hook set.

Feature: Work with husky

Problem:

Opencommit only works with git hooks.

Solution:

Refactor the code to add some dynamic logic to the tool

Explanation:

  1. Identify hooks' path in the repo you are working in. This can be accomplished with the following command:

    git config core.hooksPath

    This needed to be translated into a util function for git so I wrote the following function:

    export const getCoreHooksPath = async(): Promise<string> => {
      const { stdout } = await execa('git', [
        'config',
        'core.hooksPath']);
    
      return stdout;
    }
    

    Note: the function throws an error when there is no set path that needs to be caught when used.

  2. Determine the path by invoking getCoreHooksPath catch the error and give the DEFAULT_SYMLINK_URL if core.hooksPath is not set.

    const getHooksPath = async (): Promise<string> => {
     try {
       const hooksPath = await getCoreHooksPath();
       return `${hooksPath}/${HOOK_NAME}`;
      } catch (error) {
        return DEFAULT_SYMLINK_URL;
      }
    };
    
  3. Refactor our two helper functions to utilize the getHooksPath function.

    export const isHookCalled = async (): Promise<boolean> => {
      const hooksPath = await getHooksPath();
      return process.argv[1].endsWith(hooksPath);
    };
    
    const isHookExists = async (): Promise<boolean> => {
      const hooksPath = await getHooksPath();
      return existsSync(hooksPath);
    };
    
  4. Replace the variable calls isHookCalled and isHookExists with the function call await isHookCalled() and await isHookExists() respectively.

Scenarios Tested

When core.hooksPath is not set

  • Can you run opencommit from the command line - Yes
  • Can you set opencommit as a hook - Yes
  • Can you run open commit as a hook - Yes
  • Can you unset opencommit as a hook - Yes

When core.hooksPath is set to .husky

  • Can you run opencommit from the command line - Yes
  • Can you set opencommit as a hook - Yes
  • Can you run open commit as a hook - Yes
  • Can you unset opencommit as a hook - Yes

Allow opencommit to be installed as a devDependency

The tool looks promising, but as an avid remote dev environment (think github codespaces, gitpod) user I find it hard to install and store config globally.
I would probably need to make a custom image in order to restore the global environment each time I open the workspace.

Would you consider an .env fallback for the config values or something of sort in order to make this easier?

Configurable API endpoint

Allow to use other API offerings like the one from AzureOpenAi- which shall have compatible api but private model which is especially relevant if source code is not OS. Configuring another non default API url might already be sufficient

Request failed with status code 429

β—“  Generating the commit message.
β”‚
β””  βœ– Error: Request failed with status code 429

Introducing a minor modification (adding two new rows) to a compact file,
which consists of approximately 25 lines of code, results in an error.

What code is sent where?

Very cool tool!

As far as I can tell are only the git diff sent to ChatGPT? Am I correct or is there more?

Commits in GitKraken

First of all: wow it works great in the CLI, this is going to save me a lot of time.

Is it possible to make it work in GitKraken as well? I have set the hook, and it is recognized by the client, but I need to type a commit message before I can click the commit button.
GitKraken then says that the hook exited with error code 127. In the logs I see this: /usr/bin/env 'node': file or folder doesn't exist. When I execute /usr/bin/env node in my terminal it works, so GitKraken seems to have some sort of other context.

I tried changing the first line of the hook to #!/home/lars/.nvm/versions/node/v16.18.1/bin/node (since that is the full path to my node executable). GitKraken then says that the hook executed succesfully, but it didn't change the commit text that I needed to type to be able to click on the commit button...

What to do to fix this? Or what can I do to debug this further?

[FEATURE REQUEST] `push` automatically with a config FORCE_PUSH

  • I do not want to be asked to push commits and do not want the commits pushed by oc.
    • Alternatively, some people may want the option to automatically push commits without being asked.
  • Some people, not me, but some people may want the commit message used automatically without confirmation.

These all seem like great things to add as options IMHO.

Feature: Commit-message Prefix

We use semanic branchnames like:
feature/PROJECT-123-a-nice-new-feature or bug/PROJECT-456-oh-no-a-bug that will contain the Project ID and its Ticket Number.
The Project ID and Ticket-number are also referenced in the Commits, making it easy to link them in the Ticket. So a commit would look like the following:

PROJECT-123
chore(package.json) updates some dependencies.
feat(src/components/someComponent.tsx) Implement awesome feature

It would be nice to be able to do that with opencommit

XDG config location

It would be good if the configuration file could be located somewhere else. In particular, it would be nice to have it located where the XDG specification states (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), so you can have all your files under $XDG_CONFIG_HOME.
It should not be a difficult change and will allow us to have a cleaner home and an easier configuration backup.

The ability of setting the config file via environment variable (like OC_CONFIG=~/.opencommit), or using an environment variable to configure the software (like OPENAI_API_KEY=MyKey) would also be welcomed.

FEAT: Support to enforce conventional commits, custom scopes and amend other tool commits

Hey, first of all awesome tool

I want to know if there is something about conventional commits (or any other preset like angular) into the tool, would be awesome for workflows that use extensively commit lint.

Also, there is some way that you can choose the scope? Would be great for monorepos where scopes usually belongs to the package that is being modified.

Finally, would be great if this tool can amend the commit after the manual writing of the commit, this could help for integration with other git tools like commitizen.

Keep the awesome work!!

Error when commits are done

Howdy, thank you very much for this amazing tool.

I am using it, but I encountered an error when the commit finished, here is the error.

image

Accept / Reject + Edit

Currently one can only Accept or Reject the proposed commit message - add an option to edit the message (using $EDITOR)

zsh: command not found: oc

Hello. I entered a repository/project. Installed opencommit (oc) globally via yarn add global opencommit, and when I go to assign api key or emoji to true, I receive the above error: zsh: command not found: oc OR zsh: command not found: opencommit. I am using wsl 2 on Windows 11. I am not sure if that is the problem. I went through the same process running zsh on my MacBook and it works fine.

Commits in VSCode

Would it be possible to integrate it into VSCode? In this way, when making the commits from there, we would not have to go through the terminal.

Setting OPENAI_API_KEY throws an error : SyntaxError: Unexpected token '.'

I followed the setup steps
When I get to this step :

opencommit config set OPENAI_API_KEY=XXXXX

I get this error :

.nvm/versions/node/v12.13.0/lib/node_modules/opencommit/out/cli.cjs:15050
    throw new Error(`${n} cannot contain ${h(r2?.[0])}`);
                                                ^

SyntaxError: Unexpected token '.'
    at Module._compile (internal/modules/cjs/loader.js:892:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
    at internal/main/run_main_module.js:17:11

I tried to generate a new API key from OpenAI but it does the same.

Language settings feature

Hello,
is it possible to add feature to set language of commit message?

There are possibilities to change conversation's language in ChatGPT.

Thank you.

Error: Request failed with status code 400

β—“  Generating the commit message.
β”‚
β””  βœ– Error: Request failed with status code 400

It may be that the country I am in is not supported.
I can't find where to set it the proxy.

Feature request: add a dry run mode

Does it make sense to add a dry run mode to the oc command?

It goes like:
input:

oc --dry-run

output:

commit message: 
feat(someFeature): some message

git command:

git commit -m "feat(someFeature): some message"

Feature: How to commit with the rules of commitlint config file

I have a commit lint config file before every commits it follows the guideline of my commit rules. so how can I ensure that your opeancommit message follows the rules of my commit config.

my commit rules is :

module.exports = {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'body-leading-blank': [2, 'always'], // enforce a blank line between subject and body
    'footer-leading-blank': [2, 'always'], // enforce a blank line between body and footer
    'header-max-length': [2, 'always', 100], // enforce a maximum header length of 100 characters
    'body-empty': [2, 'never'], // enforce to write a body
    'scope-empty': [2, 'never'], // enforce a non-empty scope
    'subject-empty': [2, 'never'], // enforce a non-empty subject
    'subject-full-stop': [2, 'never', '.'], // enforce no trailing period in subject
    'type-empty': [2, 'never'], // enforce a non-empty type
    'type-enum': [
      2,
      'always',
      ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore'],
    ], // enforce a list of valid types
  },
};

[Feature Request] Pull request title based on files diff

Context

I know that the purpose of the CLI is to help create commit messages, but it would be nice to have the option to suggest pull request titles based on differences in modified files.

In this example, the user should copy the suggested title, I don't think there's a simple way to automate this.

Example

➜ opencommit --pull-request
β”Œ  open-commit
β”‚
β—‡  1 staged files:
  example-repo/test.js
β”‚
β—‡  πŸ“ Commit message generated
β”‚
β””  Commit message:
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
* feat(test.js): add test file
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

β”‚
β—‡  Confirm the commit message
β”‚  Yes
β”‚
β””  βœ” successfully committed

β”‚
β””  [main] * feat(test.js): add test file
 1 files changed, 1 insertions(+), 0 deletions(-)

β”‚
β—‡  πŸ“–  Pull Request title generated
β”‚
β””  Pull Request title:
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
* feat: Create sample test file
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

β”‚
β—‡  Do you want to run `git push`?
β”‚  Yes
β”‚
β—‡  βœ” successfully pushed all commits

Bug?: Untracked files still end up in the commit context

Don't know if this is intended or not, or if there is a config flag to disable the behavior. It seems as though making a commit in which there are some untracked files, still references the untracked files.

To reproduce:

  • Make some changes to a file
  • Add a file, but don't add it to git
  • Run git commit to activate the hook

In my case it generated a commit message that mentioned the untracked files, as well as the one file that was tracked and had changes.

Internal error when generating commit message

I am encountering an internal error when trying to generating commit message. The error message I received is " βœ– internal error, try again."

I am using OpenCommit version v1.1.10 and from VSCode bash terminal. I have already tried restart and reinstalling, but the error persists.
Error changed to :
image

Can someone please provide guidance on how to resolve this issue? Thank you.

One message for a group of x files

Would be nice to have the opportunity to configure a unique message for a batch of files.

Concrete example:

In the exampel below, I introduced a new enum and started using it inside 4 existing files. Then I would like to have a single message in a single commit that is simply "refactor: added SvgElementType constants"

So instead of:

β”‚
β—‡  4 staged files:
  src/features/Picture/screens/CanvasEdit/SvgCanvasDrawMode.js
  src/features/Picture/screens/CanvasEdit/SvgViewer.js
  src/features/Picture/screens/CanvasEdit/__tests__/SvgViewer.test.js
  src/features/Picture/screens/CanvasEdit/constants.js
β”‚
β—‡  πŸ“ Commit message generated
β”‚
β””  Commit message:
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
feat(SvgCanvasDrawMode.js): add SvgElementType constant to newElement object
feat(SvgViewer.js): add support for SvgElementType constants in ELEMENT_VIEWERS map

test(SvgViewer.test.js): add tests for SvgElementType constants
feat(constants.js): add SvgElementType constants for SVG elements
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

β”‚
β—‡  Confirm the commit message
β”‚  No
β”‚
β””  βœ– process cancelled

I would like something generating:

  • git commit -m"refactor: added SvgElementType constants"

git commit --amend

How is this use case supported? I am often doing git add -p with an initial git commit and then iterate with git add -p and git commit --amend until happy - how to generate the final commit message?

Suggestion for improving "git push"

Hi and thanks for this amazing tool!! it changes my life!! (really).

I just have a suggestion for git pushes.

I often use other divergent streams for "git push" as you can get if you type "git remote -v".
My projects have streams for deploys or just for github for example. (origin main or heroku main)

Could we maybe add something like this on line 48 of file "commit.ts"? :

const { stdout } = await execa('git', ['push', '-u', 'origin', 'HEAD']);

Option to edit the commit before accepting

The current prompt summarizes all changes in several CC commits. This is not very helpful when skimming the gitlog, as information gets lost. Also the the CC Website suggests to only use one type.

What do I do if the commit conforms to more than one of the commit types?
Go back and make multiple commits whenever possible. Part of the benefit of Conventional Commits is its ability to drive us to make more organized commits and PRs.

FAQ from ConventionalCommits

In addition to sort the text by importance - like Issue #71 suggested - I would like to see the first line summarize the changes in their entirety and/or give me the possibility to edit the text instead of just accepting or rejecting it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.