Skip to content

support hooks located in repository #367

Closed

Description

@gretel
- repo: ./pre-commit-hooks
  sha: ''
  hooks:
  - id: vault
Updating pre-commit-hooks...An unexpected error has occurred: CalledProcessError: Command: ('/usr/local/bin/git', 'clone', '--no-checkout', 'pre-commit-hooks', '/Users/gretel/.pre-commit/repoiXzY0j')
Return code: 128
Expected return code: 0
Output: (none)
Errors:
    fatal: repository 'pre-commit-hooks' does not exist

Activity

  1. asottile commented on May 3, 2016

    @asottile
    Member
  2. gretel commented on May 3, 2016

    @gretel
    Author

    this is why i was requesting to support ./ style paths. it's kinda counterfeiting the concept of using git when pre-commit requires to have static paths in it's configuration, i'd say.

  3. asottile commented on May 3, 2016

    @asottile
    Member

    I think what you actually want to use is the (still undocumented unfortunately) local hooks:
    #226

    This lets you use the current repository to configure hooks.

    The reason we can't really support relative paths is they need to refer to a universally accessible location (since hooks are cached). If we allowed relative paths, depending on cwd this could refer to a different location (and different hooks!). Local hooks aren't cached since they don't create an environment

  4. gretel commented on May 3, 2016

    @gretel
    Author

    working fine now with repo-local script. may i suggest this example to have it less-undocumented:

    -   repo: local
        hooks:
        -   id: vault
            name: Ansible Vault Check
            language: script
            description: Pre-commit hook that verifies if all files containing 'vault'
                in the name are encrypted.
            files: .*vault.*\.(yml|yaml)$
            entry: pre-commit-hooks/vault.sh
    
  5. asottile commented on May 4, 2016

    @asottile
    Member

    local hooks are now documented here: http://pre-commit.com/#repository-local-hooks

  6. added a commit that references this issue on Mar 23, 2022
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions