phpro / grumphp

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

git_commit_message not being executed #965

Closed Genero-Jay closed 2 years ago

Genero-Jay commented 2 years ago
Q A
Version 0.18.1
Bug? maybe
New feature? no
Question? yes
Documentation? no

I have added git_commit_message to the tasks to be run, but it is not run. I have put it inline with the others in my grumphp.yml, but it is not called. I'm not sure if I'm missing something, as I'm new to grumphp.

My configuration

parameters:
  hooks_directory: ./git-hooks
  ascii:
    failed: vendor/vijaycs85/drupal-quality-checker/resources/ascii/grumpy.txt
    succeeded: vendor/vijaycs85/drupal-quality-checker/resources/ascii/happy.txt
  git_dir: .
  bin_dir: vendor/bin
  tasks:
    phplint: ~
    yamllint: ~
    composer: ~
    composer_normalize: ~
    jsonlint: ~
    phpcpd:
      directory: ['./src']
    phpcs:
      standard: Drupal
      ignore_patterns:
        - .github
        - .gitlab
        - bower_components
        - node_modules
        - vendor
      triggered_by:
        - php
        - module
        - inc
        - install
        - test
        - profile
        - theme
        - css
        - info
        - txt
        - md
    git_branch_name:
      whitelist:
        - "/^JIRA-[0-9]+-(FEATURE|BUGFIX|TASK|HOTFIX)$/"
      blacklist:
        - "develop"
        - "stage"
        - "main"
      additional_modifiers: ''
      allow_detached_head: true
    git_commit_message:
      allow_empty_message: false
      enforce_capitalized_subject: true
      enforce_no_subject_punctuations: false
      enforce_no_subject_trailing_period: false
      enforce_single_lined_subject: true
      type_scope_conventions: []
      max_body_width: 72
      max_subject_width: 60
      matchers:
        Must contain JIRA issue number: '/(^JIRA-\d+(: )[^ ].{15,}\.)|(Merge branch (.)+)/'
      case_insensitive: false
      multiline: true
      additional_modifiers: ''

Your actions

Please add the steps on how to reproduce the issue here.

git commit -m "This messsage shoudln't work."

Result:

 $ git commit -m "This shoudln't work."
GrumPHP detected a pre-commit command.
GrumPHP is sniffing your code!
Running task 1/8: phplint... ✔
Running task 2/8: yamllint... ✔
Running task 3/8: composer... ✔
Running task 4/8: composer_normalize... ✔
Running task 5/8: jsonlint... ✔
Running task 6/8: phpcpd... ✔
Running task 7/8: phpcs... ✔
Running task 8/8: git_branch_name... ✔
[JIRA-41-TASK e50a86e] This shoudln't work.
Genero-Jay commented 2 years ago

Oops, I had my git hooks in a custom directory, and I needed to move the pre-commit file from .git/hooks to my custom git hooks directory.