Skip to content

Conversation

@leshy
Copy link
Contributor

@leshy leshy commented Jan 30, 2026

Avoids running pre-commit install on every shell entry when hooks are already set up.

@greptile-apps
Copy link

greptile-apps bot commented Jan 30, 2026

Greptile Overview

Greptile Summary

Added a check to skip pre-commit install --install-hooks on shell entry if hooks are already installed, preventing redundant installation.

  • Only verifies .git/hooks/pre-commit exists, but the configuration installs two hook types: pre-commit and commit-msg
  • If commit-msg hook is missing while pre-commit exists, installation will be incorrectly skipped

Confidence Score: 2/5

  • This PR has a logic bug that could prevent proper hook installation
  • The check only verifies one of two required hook files, which means the commit-msg hook may not be installed in some scenarios
  • flake.nix:227 needs to check for both hook files

Important Files Changed

Filename Overview
flake.nix Added check to skip pre-commit install, but only verifies one of two required hook files

Sequence Diagram

sequenceDiagram
    participant Shell as Shell Entry
    participant Script as shellHook Script
    participant Git as Git Repository
    participant PreCommit as pre-commit

    Shell->>Script: Enter dev shell
    Script->>Git: Check for .pre-commit-config.yaml
    
    alt Config exists
        Script->>Git: Check for .git/hooks/pre-commit
        
        alt Hook exists (NEW CHECK)
            Script->>Script: Skip installation
            Note over Script,PreCommit: Optimization: avoid redundant install
        else Hook missing
            Script->>PreCommit: pre-commit install --install-hooks
            PreCommit->>Git: Install pre-commit hook
            PreCommit->>Git: Install commit-msg hook
            Note over PreCommit,Git: Issue: commit-msg not verified!
        end
    else Config missing
        Script->>Script: Skip installation
    end
    
    Script->>Shell: Continue shell initialization
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@leshy leshy changed the title Skip pre-commit install if hooks already exist nix: Skip pre-commit install if hooks already exist Jan 30, 2026
Copy link
Member

@jeff-hykin jeff-hykin left a comment

Choose a reason for hiding this comment

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

LGTM

@paul-nechifor paul-nechifor merged commit 130108a into dev Jan 31, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants