Skip to content

fix(envrc): correct hooks detection for worktrees and refresh tooling hints#598

Merged
CybotTM merged 2 commits intomainfrom
fix/envrc-worktree-detection
May 6, 2026
Merged

fix(envrc): correct hooks detection for worktrees and refresh tooling hints#598
CybotTM merged 2 commits intomainfrom
fix/envrc-worktree-detection

Conversation

@CybotTM
Copy link
Copy Markdown
Member

@CybotTM CybotTM commented May 6, 2026

Summary

  • The hooks check used .git/hooks/pre-commit literally, so it always reported "not configured" inside a git worktree (where .git is a file). Switched to git rev-parse --git-path hooks so detection works for both regular repos and worktrees.
  • Dropped the dead Husky branch + missing install-husky.sh reference (project already migrated to lefthook).
  • Bumped REQUIRED_VERSION 1.25 → 1.26 to match go.mod.
  • Fixed the gosec install hint (404 repo + non-existent snap pkg) to the canonical go install github.com/securego/gosec/v2/cmd/gosec@latest.
  • Removed forced CGO_ENABLED=0 / GOOS=linux / GOARCH=amd64 exports. These belong in build commands, not a per-shell env — forcing CGO off silently breaks go test -race, and pinning GOOS/GOARCH breaks non-amd64 dev hosts.
  • Replaced the hardcoded "60.1% coverage" claim with a pointer to make test-coverage so it can't drift.

Test plan

  • bash -n .envrc passes
  • In a worktree: detection now returns ✅ Git hooks configured (lefthook) instead of nagging
  • Commit signed off (DCO)
  • CI green

Copilot AI review requested due to automatic review settings May 6, 2026 08:16
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

github-actions[bot]
github-actions Bot previously approved these changes May 6, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for maintainer PR

All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the .envrc file to bump the required Go version to 1.26, improves Git hook detection for worktrees, and streamlines tool installation commands. It also removes hardcoded Go environment variables and simplifies the hook verification logic. Review feedback identifies several areas where these changes are incomplete or inconsistent with other project files, including missing updates for the Go version in error messages, gosec installation methods in the Makefile, worktree support in lefthook.yml, and hardcoded test coverage values.

Comment thread .envrc Outdated
Comment thread .envrc Outdated
Comment thread .envrc
Comment thread .envrc
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.26%. Comparing base (1f6109a) to head (2a1c593).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #598      +/-   ##
==========================================
- Coverage   87.28%   87.26%   -0.02%     
==========================================
  Files          88       88              
  Lines       10631    10631              
==========================================
- Hits         9279     9277       -2     
- Misses       1112     1113       +1     
- Partials      240      241       +1     
Flag Coverage Δ
integration 87.15% <ø> (-0.14%) ⬇️
unittests 83.78% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the repo’s direnv bootstrap (.envrc) to better reflect current tooling expectations and to correctly detect lefthook-based git hooks in both regular repos and git worktrees.

Changes:

  • Bump the required Go version hint to 1.26 to align with go.mod.
  • Fix git hooks detection in worktrees by resolving the hooks path via git rev-parse --git-path hooks.
  • Refresh developer tooling hints (e.g., gosec install) and remove hardcoded GOOS/GOARCH/CGO environment exports.

Comment thread .envrc Outdated
Comment thread .envrc Outdated
Comment thread .envrc Outdated
CybotTM added a commit that referenced this pull request May 6, 2026
- .envrc:23 missed the Go-version bump message; align with REQUIRED_VERSION.
- .envrc:30 numeric awk comparison treated 1.9 as >= 1.26; split major/minor
  and compare as integers.
- .envrc:60 git rev-parse can fail (no git, not in a repo) and set -e would
  abort the whole .envrc; guard the call and skip the hooks check cleanly.
- lefthook.yml:174 had the same `.git/hooks/pre-commit` hardcoded path that
  fails in worktrees; mirror the .envrc fix.
- Makefile: drop the snap/securecodewarrior/gosec install hints (snap pkg
  doesn't exist; the repo URL is 404) and use
  `go install github.com/securego/gosec/v2/cmd/gosec@latest` consistently.
- Makefile:300 still hardcoded "60.1%" coverage; replace with a pointer to
  `make test-coverage` so it can't drift.

Addresses gemini-code-assist and Copilot review comments on PR #598.

Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
@github-actions github-actions Bot added the ci label May 6, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for maintainer PR

All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.

CybotTM added 2 commits May 6, 2026 11:44
… hints

The hooks check used a literal `.git/hooks/pre-commit` path, which fails in
git worktrees (where `.git` is a file pointing to the worktree's gitdir).
Replace with `git rev-parse --git-path hooks` so detection works for both
regular repos and worktrees.

While here:
- Drop the dead Husky branch and the missing `install-husky.sh` reference
  (project migrated to lefthook; only `install-hooks.sh` remains).
- Bump `REQUIRED_VERSION` from 1.25 to 1.26 to match `go.mod`.
- Fix the `gosec` install hint (404 repo + non-existent snap package) to
  the canonical `go install github.com/securego/gosec/v2/cmd/gosec@latest`.
- Stop forcing `CGO_ENABLED=0`, `GOOS=linux`, `GOARCH=amd64`. These belong
  in build commands, not a per-shell env: forcing CGO off silently breaks
  `go test -race`, and pinning GOOS/GOARCH breaks non-amd64 dev hosts.
- Replace the hardcoded "60.1% coverage" claim with a pointer to
  `make test-coverage` so the help text doesn't drift.

Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
- .envrc:23 missed the Go-version bump message; align with REQUIRED_VERSION.
- .envrc:30 numeric awk comparison treated 1.9 as >= 1.26; split major/minor
  and compare as integers.
- .envrc:60 git rev-parse can fail (no git, not in a repo) and set -e would
  abort the whole .envrc; guard the call and skip the hooks check cleanly.
- lefthook.yml:174 had the same `.git/hooks/pre-commit` hardcoded path that
  fails in worktrees; mirror the .envrc fix.
- Makefile: drop the snap/securecodewarrior/gosec install hints (snap pkg
  doesn't exist; the repo URL is 404) and use
  `go install github.com/securego/gosec/v2/cmd/gosec@latest` consistently.
- Makefile:300 still hardcoded "60.1%" coverage; replace with a pointer to
  `make test-coverage` so it can't drift.

Addresses gemini-code-assist and Copilot review comments on PR #598.

Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
@CybotTM CybotTM force-pushed the fix/envrc-worktree-detection branch from c3122ea to 2a1c593 Compare May 6, 2026 09:44
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for maintainer PR

All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.

@CybotTM CybotTM added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit d32bab8 May 6, 2026
26 checks passed
@CybotTM CybotTM deleted the fix/envrc-worktree-detection branch May 6, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants