phpro / grumphp

A PHP code-quality tool
MIT License
4.13k stars 430 forks source link

Git Pre Commit hooks are not fired. Other Pre hooks like GitLeaks does get fired. #910

Closed vaibhavjain-in closed 3 years ago

vaibhavjain-in commented 3 years ago
Q A
Version GrumPHP 1.3.2
Bug? yes
New feature? no
Question? yes
Documentation? no
Related tickets NONE

I have added grumphp via composer, added and modified grumphp.yml.dist. I deliberately break things for PHPCS, Git commit message and others, but the hook never gets fired. I may be missing something, but not sure what.

My configuration

# grumphp.yml.dist
parameters:
  git_dir: .
  bin_dir: vendor/bin
grumphp:
  ascii:
    failed: drupal/drupal-ascii.txt
    succeeded: drupal/drupal-ascii.txt
  parallel:
    enabled: true
    max_workers: 32
  tasks:
    composer: ~
    composer_normalize: ~
    git_blacklist:
      keywords:
        - "die\\("
        - "var_dump\\("
        - "exit;"
        - "die;"
        - "dpr\\("
        - "dsm\\("
        - "kint\\("
      whitelist_patterns:
        - docroot/modules/custom
        - docroot/themes/custom
        - docroot/profiles/custom
      triggered_by:
        - inc
        - install
        - module
        - php
        - profile
        - theme
        - twig
    git_commit_message:
      enforce_no_subject_trailing_period: false
      max_body_width: 0
      max_subject_width: 0
      matchers:
        Must contain JIRA issue number: /SSU-\d+/
    phpcs:
      standard:
        - vendor/drupal/coder/coder_sniffer/Drupal
        - vendor/drupal/coder/coder_sniffer/DrupalPractice
      whitelist_patterns:
        - docroot/modules/custom
        - docroot/themes/custom
        - docroot/profiles/custom
      triggered_by:
        - inc
        - install
        - module
        - php
        - profile
        - theme
    twigcs:
      path: 'docroot/themes/custom'
      ruleset: 'FriendsOfTwig\Twigcs\Ruleset\Official'
      exclude:
        - core
        - modules/contrib
        - themes/contrib
        - profiles/contrib
    yamllint:
      whitelist_patterns:
        - docroot/modules/custom
        - docroot/themes/custom
        - docroot/profiles/custom

Steps to reproduce:

# Generate empty folder
mkdir tmp
cd tmp
git init
echo "vendor" > .gitignore
pbpaste > grumphp.yml
composer require --dev phpro/grumphp

# Your actions
# Please add the steps on how to reproduce the issue here.

# Run GrumPHP:
git add -A && git commit -m"Test"
# or
./vendor/bin/grumphp run

Result:

# The commit is made and it does not activate the pre commit hook.
vaibhavjain-in commented 3 years ago

Please ignore this. This is an issue with my git hooks settings. My hooksPath is set to ~/.git-hooks, which is global, whereas it should be project specific.