Skip to content

Auto-install overwrites global hooks when core.hooksPath is external #231

@nshkrdotcom

Description

@nshkrdotcom

Summary

When core.hooksPath points to a global/shared directory, mix compile (auto-install) or mix git_hooks.install writes hooks into that directory and overwrites existing hooks with project-specific scripts.

Repro

  1. git config --global core.hooksPath ~/.config/git/hooks (or any shared path)
  2. In a repo with git_hooks auto-install enabled, run mix compile (or mix git_hooks.install)
  3. Observe hooks written into ~/.config/git/hooks with the repo project_path hardcoded

Expected

If the resolved hooks path is outside the repo, refuse install by default (warn) unless explicitly opted in.

Actual

Hooks are installed into the external hooks directory and clobber existing global hooks.

Proposed fix

Before installing, check whether git rev-parse --git-path hooks resolves inside the repo root. If not, skip with a warning unless allow_external_hooks_path: true or GIT_HOOKS_ALLOW_EXTERNAL=1 is set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions