Skip to content

Commit

Permalink
✨ Merge from upstream 'di-sukharev/master'
Browse files Browse the repository at this point in the history
Upgrade to 2.4.2 from upstream

🐛fix(api.ts, checkIsLatestVersion.ts): fix npm command to get the latest version of opencommit
    Fixed the npm command to get the latest version of opencommit. Previously, it was using `npm view opencommit version`, but it has been updated to `npm view github:takuya-o/opencommit version` to specify the correct package name.

🐛修正(api.ts, checkIsLatestVersion.ts): opencommitの最新バージョンを取得するためのnpmコマンドを修正しました
    opencommitの最新バージョンを取得するためのnpmコマンドを修正しました。以前は`npm view opencommit version`を使用していましたが、正しいパッケージ名を指定するために`npm view github:takuya-o/opencommit version`に変更しました。

⬆️ Update(package.json): Add script to upgrade packages using npm-check-updates and run npm update and npm dedup
    To make it easier to upgrade packages and manage dependencies, a new script called "upgrade" has been added. This script uses npm-check-updates to upgrade packages to their latest versions, runs npm update to update dependencies, and runs npm dedup to remove duplicate packages.

⬆️ アップデート(package.json): npm-check-updatesを使用してパッケージをアップグレードし、npm updateとnpm dedupを実行するスクリプトを追加しました
パッケージのアップグレードと依存関係の整理を簡単にするために、新しいスクリプト"upgrade"を追加しました。このスクリプトは、npm-check-updatesを使用してパッケージを最新バージョンにアップグレードし、npm updateを実行して依存関係を更新し、npm dedupを実行して重複したパッケージを削除します。

Merge branch 'revert-async-prefix' into 'azure'
Revert "Merge remote-tracking branch 'amyu98/allowForCommitPrefix' into try-commit-prefix"
非同期化したprefix付加機能を巻き戻した
  • Loading branch information
takuya-o committed Jul 22, 2023
1 parent 3796ae0 commit 42a34ca
Show file tree
Hide file tree
Showing 16 changed files with 896 additions and 954 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `dev` branch. Not `master` branch, PR to `dev` branch, please.

## Getting started

Expand Down
Binary file added .github/github-mark-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 60 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<img src=".github/logo-grad.svg" alt="OpenCommit logo"/>
<h1 align="center">OpenCommit</h1>
<h4 align="center">Follow the bird <a href="https://twitter.com/io_Y_oi"><img src="https://img.shields.io/twitter/follow/io_Y_oi?style=flat&label=io_Y_oi&logo=twitter&color=0bf&logoColor=fff" align="center"></a>
</h4>
</div>
<h2>Auto-generate meaningful commits in 1 second</h2>
<p>Killing lame commits with AI 🤯🔫</p>
<a href="https://www.npmjs.com/package/opencommit"><img src="https://img.shields.io/npm/v/opencommit" alt="Current version"></a>
<h4 align="center">🪩 Winner of GitHub 2023 HACKATHON <a href="https://twitter.com/io_Y_oi"><img style="width:18px; height:18px;" src=".github/github-mark-white.png" align="center"></a>
</h4>
</div>

---
Expand All @@ -16,15 +17,35 @@
<img src=".github/opencommit-example.png" alt="OpenCommit example"/>
</div>

All the commits in this repo are done with OpenCommit — look into [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emoji and long commit description text is configurable.
All the commits in this repo are authored by OpenCommit — look at [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emojis and long commit descriptions are configurable.

## Setup OpenCommit as a Github Action 🔥
## 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:

```sh
npm install -g opencommit
```

2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure that you add your payment details, so the API works.

3. Set the key to OpenCommit config:

```sh
opencommit config set OCO_OPENAI_API_KEY=<your_api_key>
```

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

## Setup OpenCommit as a GitHub Action 🔥

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 repository branches are meaningful and not lame like `fix1` or `done2`.
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 contents below:
Create a file `.github/workflows/opencommit.yml` with the contents below:

```yml
name: 'OpenCommit Action'
Expand Down Expand Up @@ -68,31 +89,11 @@ jobs:
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.
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 when improving the messages.
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 commit SHA, so commit history in remote becomes different with your local branch history. It's ok when you work on the branch alone, but may be inconvenient for other collaborators.

## Setup OpenCommit as a CLI

You can use OpenCommit by simply running it via 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:

```sh
npm install -g opencommit
```

2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure you add payment details, so API works.

3. Set the key to OpenCommit config:

```sh
opencommit config set OCO_OPENAI_API_KEY=<your_api_key>
```

Your api key is stored locally in `~/.opencommit` config file.
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.

## Usage

Expand All @@ -107,30 +108,31 @@ You can also use the `oco` shortcut:

```sh
git add <files...>
oc
oco
```

## Configuration

### Local per repo configuration

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

```env
OCO_OPENAI_API_KEY=<your openAI API token>
OCO_OPENAI_MAX_TOKENS=<max response tokens from openAI API>
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to openAI api>
OCO_OPENAI_API_KEY=<your OpenAI API token>
OCO_OPENAI_MAX_TOKENS=<max response tokens from OpenAI API>
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to OpenAI api>
OCO_DESCRIPTION=<postface a message with ~3 sentences description>
OCO_EMOJI=<add GitMoji>
OCO_MODEL=<either gpt-3.5-turbo or gpt-4>
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=<message template placeholder, example: '$msg'>
```

### Global config for all repos

Local config still has more priority as 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.
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 run any of the variable above like this:
Simply set any of the variables above like this:

```sh
oco config set OCO_OPENAI_API_KEY=gpt-4
Expand All @@ -142,7 +144,7 @@ Configure [GitMoji](https://gitmoji.dev/) to preface a message.
oco config set OCO_EMOJI=true
```

To remove preface emoji:
To remove preface emojis:

```sh
oco config set OCO_EMOJI=false
Expand All @@ -162,17 +164,23 @@ Of course need to set 'OCO_OPENAI_API_KEY'. And also need to set the
'OCO_OPENAI_BASE_PATH' for the endpoint and set the deployment name to
'model'.

### Switch to GPT-4
### Switch to GPT-4 or other models

By default OpenCommit uses GPT-3.5-turbo (ChatGPT).
By default, OpenCommit uses `gpt-3.5-turbo-16k` model.

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

```sh
oco config set OCO_MODEL=gpt-4
```

Make sure you do lowercase `gpt-4` and you have API access to the 4th model. Even if you have ChatGPT+ it doesn't necessarily mean that you have API access to GPT-4.
or for as a cheaper option:

```sh
oco config set OCO_MODEL=gpt-3.5-turbo
```

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

Expand All @@ -190,7 +198,7 @@ oco config set OCO_LANGUAGE=French
oco config set OCO_LANGUAGE=française
```

The default language set is **English**
The default language setting 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
Expand All @@ -214,22 +222,30 @@ 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:

```sh
oco '$msg #205’
```
> 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!"
### Ignore files
You can ignore files from submission to OpenAI by creating a `.opencommitignore` file. For example:
You can remove files from being sent to OpenAI by creating a `.opencommitignore` file. For example:
```ignorelang
path/to/large-asset.zip
**/*.jpg
```
This is useful for preventing opencommit from uploading artifacts and large files.
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`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. Hook integrates with you IDE Source Control and allows you edit the message before commit.
You can set OpenCommit as Git [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. Hook integrates with your IDE Source Control and allows you to edit the message before committing.
To set the hook:
Expand All @@ -254,4 +270,4 @@ Or follow the process of your IDE Source Control feature, when it calls `git com
## Payments
You pay for your own requests to OpenAI API. OpenCommit uses ChatGPT (3.5-turbo) official model, that is ~15x times cheaper than GPT-4.
You pay for your requests to OpenAI API. OpenCommit uses ChatGPT (3.5-turbo) official model, which is ~15x times cheaper than GPT-4.
Loading

0 comments on commit 42a34ca

Please sign in to comment.