Skip to content

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

Open
@bjornsnoen

Description

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 [Bug]: Unsupported config key OCO_AZURE_ENDPOINT - even when provider is set to openai #352 (comment)
  3. Install git hook with oco hook set
  4. Run git commit

Relevant log output

No response

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions