Skip to content

fix(hooks): run every pre-commit hook natively on Windows #229

Closed

Description

@DevSecNinja

Problem

The lefthook renovate-helper pre-commit check fails on Windows with WinError 193. Its test fixture is a fake gh shell script, which Windows can't run as a Win32 executable. Every Windows commit has to set LEFTHOOK_EXCLUDE=renovate-helper, even when the change doesn't touch the Renovate helper. The SkillSpector PRs (#215/#218) and #228 both ran into it. The check passes on Linux and under WSL.

Proposed solution

  • Make the fixture work on Windows: invoke it through the interpreter (for example sys.executable with a Python fake, or bash explicitly), or provide a .cmd shim.
  • Alternatively, skip only that fixture-based test on Windows, with a clear reason, while CI keeps running it on Linux.
  • Confirm lefthook run pre-commit passes on Windows without exclusions.

Alternatives considered

Keep excluding the hook on Windows by hand: it's easy to forget, and it hides real failures.

Activity

  1. changed the title [-]fix(hooks): make the renovate-helper pre-commit check work on Windows[/-] [+]fix(hooks): run every pre-commit hook natively on Windows[/+] on Nov 15, 2026
  2. DevSecNinja commented on Nov 15, 2026

    @DevSecNinja
    OwnerAuthor

    Scope extended (2026-11-15, owner-approved): make every pre-commit hook run natively on Windows, not just renovate-helper.

    Six lefthook commands call python3 directly (renovate-helper, release-please-config, apm-manifest, apm-overrides, skillspector-gate, plus any added later). On Windows, python3 usually resolves to the Microsoft Store stub (%LOCALAPPDATA%\Microsoft\WindowsApps\python3.exe), which runs no code, so sessions fall back to WSL or skip hooks. The two Bash hooks run fine under Git for Windows bash.

    Plan:

    • Add one small launcher (for example scripts/py, a POSIX sh script that lefthook runs through Git bash on Windows). It picks the first real interpreter of a minimum version (match CI; check python-version in the workflows) from python3, py -3, python. It skips the WindowsApps Store stub, and fails with a clear message ("install Python ≥ X, or disable the python3 App execution alias") when none qualifies.
    • Switch every Python lefthook command to the launcher.
    • Fix the renovate-helper fixture (WinError 193): run the fake gh through the interpreter, or use a .cmd shim, so the test passes on Windows.
    • CI: run the lefthook pre-commit suite on a windows-latest job as well (lefthook run pre-commit --all-files, or the same unittest commands through the launcher), so a Windows regression fails the PR. Keep it cheap: path-filtered to hooks, tests and scripts.
    • Document it in CONTRIBUTING.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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