Bite before you commit: a pre-commit hook

Open Beginner friendly
#87 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
85/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
git, python, yaml

Research direction

Create .pre-commit-hooks.yaml at the repo root with a bite-live hook that runs bite live. Edit README to add the config lines and explain the double test run and git commit --no-verify skip. Verify by adding the hook to a test project and confirming bite live runs on commit. Done when README documents setup and the hook works.

Written by the indexing model from the issue text.

Description

enhancement help wanted

Size: small to medium. An afternoon. No API key needed.

What and why
pre-commit runs checks on every git commit in thousands of projects. bite live already checks the changes you haven't committed yet: it takes them out of a copy and runs your tests. If a hook ran bite live, people would get Bite on every commit without thinking about it: "you changed this, and no test would notice if it vanished."

What to do

  1. Add .pre-commit-hooks.yaml at the top of this repo:
    - id: bite-live
      name: Bite (would a test notice this change?)
      entry: bite live
      language: python
      pass_filenames: false
      always_run: true
    
    pass_filenames: false matters: bite live works out the changes itself, and the file names pre-commit would add aren't options it knows.
  2. In README.md, under "Check Claude's "fixed" live", add a short "Before every commit (pre-commit)" part with the lines a project puts in its .pre-commit-config.yaml:
    repos:
      - repo: https://github.com/connabyss/bite
        rev: v1.0.5   # the first release that has the hook; use the newest
        hooks:
          - id: bite-live
    
  3. The README part must say these plainly:
    • It checks only the change you're committing, not old commits.
    • It runs your tests twice (with the change, then without), so each commit waits about twice as long as your tests take. free_test_command in .bite.ini can point it at a faster subset.
    • When no test notices the change, bite live exits with 1 and the commit stops. To skip it once: git commit --no-verify.
    • It also counts new files you haven't added to git (pre-commit doesn't hide those), so keep scratch files out of the project folder or in .gitignore.

Done when

  • A test in tests/ reads .pre-commit-hooks.yaml as text and checks the id is bite-live, the entry is bite live, and pass_filenames: false is there (no YAML package needed, Bite has no dependencies).
  • You tried it for real on a scratch repo with pre-commit try-repo <path to your bite clone> bite-live --all-files, once where a test notices (passes) and once where none does (stops the commit), and pasted both outputs into the PR.
  • The README part has the setup lines and the four points above.

Heads-up: on a brand-new repo with no commits yet, bite live currently says "--since HEAD isn't a commit" and stops the very first commit. That's #173; if nobody has fixed it yet, mention it in your PR rather than fixing both.

New here? CONTRIBUTING.md has setup (pip install -e .[test], then python -m pytest). Comment to claim it.

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

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 connabyss/bite

All issues in connabyss/bite

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.