di-sukharev / opencommit

Generate conventional git commit messages with AI in 1 second 🤯🔫
https://www.npmjs.com/package/opencommit
MIT License
5.97k stars 318 forks source link

[Bug]: OpenCommit GitHub Action Re-running #201

Open NorkzYT opened 1 year ago

NorkzYT commented 1 year ago

Opencommit Version

di-sukharev/opencommit@github-action-v1.0.4

Node Version

16

NPM Version

Unknown

What OS are you seeing the problem on?

Windows

What happened?

Each time a commit is initiated, the OpenCommit GitHub Action applies modifications. Consequently, VSCode prompts the user to synchronize these changes by initiating a push command. Upon acceptance, a new commit is added with the message, Merged from $BRANCH to $BRANCH. Once the OpenCommit GitHub Action completes its execution, the commit message is reverted to the preceding one.

Re-pushes commits even though there are no file changes. image

opencommit.yml:

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/opencommit@github-action-v1.0.4
        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_OPENAI_MAX_TOKENS: 500
          OCO_OPENAI_BASE_PATH: ''
          OCO_DESCRIPTION: true
          OCO_EMOJI: true
          OCO_MODEL: gpt-3.5-turbo
          OCO_LANGUAGE: en

Expected Behavior

There should not be any re-commits created after the OpenCommit Action completes it's run.

Current Behavior

Look at the following image for an example of the repeating commit messages. image

Possible Solution

Currently I do not know of a possible solution other than the fact that a setting in Vscode may be the cause or the GitHub Action.

Steps to Reproduce

Setup GitHub Action, Change a file, Commit the file, and GitHub Action Completes.

Relevant log output

End of the GitHub Action of OpenCommit when there are no new commits:

Improved 2 commits:  [
  {
    sha: '21ca2a509870626c64f6427c357d26e1fce9769f',
    msg: '🔥 chore(opencommit.yml): remove duplicated and unnecessary customization options\n' +
      'The duplicated and unnecessary customization options were removed to improve the readability of the file.'
  },
  {
    sha: '0ad612ed1cb6e8d0324c5fb67d2994007a307bd0',
    msg: "I'm sorry, I didn't receive any input. Please provide me with the output of 'git diff --staged' command so I can help you create a commit message."
  }
]
/usr/bin/chmod +x ./rebase-exec.sh
/usr/bin/git rebase 21ca2a509870626c64f6427c357d26e1fce9769f^ --exec ./rebase-exec.sh
Rebasing (2/4)

Executing: ./rebase-exec.sh
[detached HEAD 1c1ee1b] 🔥 chore(opencommit.yml): remove duplicated and unnecessary customization options The duplicated and unnecessary customization options were removed to improve the readability of the file.
 Author: Norkz
 Date: Wed Jun 7 23:17:53 2023 -0400
 1 file changed, 1 insertion(+), 9 deletions(-)
Rebasing (3/4)
Rebasing (4/4)

Executing: ./rebase-exec.sh
You asked to amend the most recent commit, but doing so would make
it empty. You can repeat your command with --allow-empty, or you can
remove the commit entirely with "git reset HEAD^".
interactive rebase in progress; onto 22fa8a4
Last commands done (4 commands done):
   pick 17c97de 🔥 chore(opencommit.yml): remove duplicated and unnecessary customization options The duplicated and unnecessary customization options were removed to improve the readability of the file.
   exec ./rebase-exec.sh
  (see more in file .git/rebase-merge/done)
No commands remaining.
You are currently editing a commit while rebasing branch 'BRANCH' on '22fa8a4'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    commit-0.txt
    commit-1.txt
    count.txt
    rebase-exec.sh

No changes

Successfully rebased and updated refs/heads/BRANCH.
│
└  Force pushing non-interactively rebased commits into remote.

/usr/bin/git status
On branch BRANCH
Your branch and 'origin/BRANCH' have diverged,
and have 2 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean
/usr/bin/git push --force
remote: Resolving deltas:   0% (0/4)        
remote: Resolving deltas:  25% (1/4)        
remote: Resolving deltas:  50% (2/4)        
remote: Resolving deltas:  75% (3/4)        
remote: Resolving deltas: 100% (4/4)        
remote: Resolving deltas: 100% (4/4), completed with 3 local objects.        
To https://github.com/REPO
 + 0ad612e...d29584b BRANCH -> BRANCH (forced update)
│
└  Done 🧙
malpou commented 1 year ago

I'm seeing the same thing happening in my repo.

malpou commented 1 year ago

This should be fixed in this PR I've created #222

github-actions[bot] commented 1 year ago

Stale issue message