Files
hermes-agent/lefthook.yml
Teknium ff19b196ba fix(dev): desktop/TUI pre-commit lint runs from a linked worktree again
The `{just}` template resolves `$(git rev-parse --show-toplevel)/scripts/hook-just`.
Git exports GIT_DIR to hooks in a linked worktree, and with GIT_DIR set
`--show-toplevel` answers the current directory instead of the worktree root. The
`root: apps/desktop/` (and ui-tui, shared, web, tests) jobs run there, so every
worktree commit touching those trees failed with
"cannot open apps/desktop/scripts/hook-just". Main-checkout commits were unaffected
(no GIT_DIR export), and Python-only commits too (their jobs run at the root).

Resolve the root with GIT_DIR unset. Regression: 27896fd2cd.
2026-11-22 01:06:50 -08:00

53 lines
1.8 KiB
YAML

# The command the generated git hooks run instead of searching PATH, node_modules and
# finally `uv run lefthook`, which syncs `.venv` and editable-installs the checkout into it
# (scripts/run-lefthook). No double quotes in the value: lefthook pastes it into
# `test -n "..."`. A commit that predates the script skips the hooks instead of failing.
lefthook: "sh -c 'if test -f scripts/run-lefthook; then exec sh scripts/run-lefthook $0 $*; fi; echo git hooks skipped: this checkout has no scripts/run-lefthook >&2'"
# `just` for the jobs, resolved only for a job whose glob matched (scripts/hook-just), so a
# commit no job matches never sets up an environment. Absolute: `root:` jobs run in a subdir.
# `env -u GIT_DIR`: git exports GIT_DIR to hooks in a linked worktree, and with it set
# `--show-toplevel` answers the job's cwd (apps/desktop/), not the checkout.
templates:
just: sh "$(env -u GIT_DIR git rev-parse --show-toplevel)/scripts/hook-just"
pre-commit:
jobs:
- name: lint python
glob: "*.py" # glob filter
run: "{just} ruff {staged_files}"
- name: move shims
glob: "*.py"
run: "{just} check --only shims"
- name: lint web
root: web/
glob: "web/**/*.{js,ts,tsx}"
run: "{just} eslint {staged_files}"
- name: lint bootstrap installer
root: apps/bootstrap-installer/
glob: "*.{js,ts,tsx}"
run: "{just} eslint {staged_files}"
- name: lint desktop app
root: apps/desktop/
glob: "*.{js,ts,tsx}"
run: "{just} eslint {staged_files}"
- name: lint tui
root: ui-tui/
glob: "*.{js,ts,tsx}"
run: "{just} eslint {staged_files}"
- name: lint shared
root: apps/shared/
glob: "*.{js,ts,tsx}"
run: "{just} eslint {staged_files}"
- name: lint tests
root: tests-js/
glob: "*.{js,ts,tsx}"
run: "{just} eslint {staged_files}"