opencommit icon indicating copy to clipboard operation
opencommit copied to clipboard

[Bug]: Hook needs env vars set even when using ollama

Open bjornsnoen opened this issue 10 months ago • 1 comments

Opencommit Version

3.2.5

Node Version

18.18.2

NPM Version

9.8.1

What OS are you seeing the problem on?

Other Linux Distro

What happened?

A bug happened!

Expected Behavior

I used oco hook set to install the prepare commit msg hook and tried to run git commit, which produced the following error message:

┌  opencommit
│
â””  No OCO_API_KEY is set. Set your key via `oco config set OCO_API_KEY=<value>. For more info see https://github.com/d
i-sukharev/opencommit

Simply running oco does work as expected but I'd like to be able to edit the commit message.

This is my .opencommit config:

OCO_MODEL=mistral
OCO_API_URL=http://localhost:11434/api/chat
OCO_API_KEY=undefined
OCO_AI_PROVIDER=ollama
OCO_TOKENS_MAX_INPUT=40960
OCO_TOKENS_MAX_OUTPUT=4096
OCO_DESCRIPTION=false
OCO_EMOJI=false
OCO_LANGUAGE=en
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=$msg
OCO_PROMPT_MODULE=conventional-commit
OCO_ONE_LINE_COMMIT=false
OCO_TEST_MOCK_TYPE=commit-message
OCO_GITPUSH=false
OCO_WHY=false

Current Behavior

Commit gets interrupted with the message above.

Possible Solution

Unify config handling between hook and regular command mode.

Steps to Reproduce

  1. Set provider to ollama with oco config set OCO_AI_PROVIDER=ollama
  2. Clean up config file according to https://github.com/di-sukharev/opencommit/issues/352#issuecomment-2186908034
  3. Install git hook with oco hook set
  4. Run git commit

Relevant log output

No response

bjornsnoen avatar Dec 17 '24 09:12 bjornsnoen