okl init --no-git-hook should remove okl's own pre-push hook, not just stop installing it

Open Beginner friendly
#147 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
73/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
git, github-actions, python
Domain
cli, devtools

Research direction

Start in cli/install.py, where the cfg["git_hook"] branch calls _install_git_hook, and inspect the existing --uninstall logic for ownership checks and user messaging. Add or locate tests for switching an installed-hook repo to --ci --no-git-hook, including the MODIFIED-hook case. Done means an untouched okl hook is removed with notice, while edited or third-party hooks are preserved and the user is told what to remove.

Written by the indexing model from the issue text.

Description

enhancement

What happens

A repo whose earlier okl init installed the pre-push drift gate decides to gate drift in CI instead:

okl init --ci --no-git-hook

init installs the workflow and records git_hook: false, but the installed hook stays and keeps running. It still blocks every push on drift, so the switch to CI did not happen as the person meant.

Found by CodeRabbit on #146. The docs there now describe the behaviour as it is: "A hook an earlier init installed stays: --no-git-hook only stops init installing it, and okl init --uninstall removes it."

Cause

cfg["git_hook"] decides only whether _install_git_hook runs (cli/install.py, the if cfg["git_hook"] branch). Nothing removes okl's hook when the recorded choice turns false. The only code that deletes it is okl init --uninstall.

Proposal

When --no-git-hook is passed (or the recorded choice is false) and the hook in git's hooks directory is okl's own, untouched copy (ownership.status == OKL), remove it and say so. Leave an edited copy (MODIFIED) or another tool's hook alone, and print the line to take out instead, as --uninstall does today. Test it by switching a repo from the hook to --ci --no-git-hook, and check that an edited hook is kept.

🤖 Generated with Claude Code

Dominant language
Python
Stars
1
Forks
1
Avg merge
5h 10m
Merged PRs (30d)
127

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from emeraldleaf/okl

All issues in emeraldleaf/okl

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.