Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

I updated `spryker/git-hook` recently and my pre commit hook is failing now with: ```ERROR: the "APP

Options
U01LKKBK97T
U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet

I updated spryker/git-hook recently and my pre commit hook is failing now with:

ERROR: the "APPLICATION_ROOT_DIR/phpcs.xml" coding standard is not installed. The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend, config, mpdf, SlevomatCodingStandard, decimal-object, development, GlueStreamSpecific, Spryker and SprykerStrict

Seems it's related to this commit: https://github.com/spryker/git-hook/commit/ce5f46583fb9d98db7983c08b89187915c0d06b9

I haven't had a phpcs.xml on project level so far and I'd like to keep using it from the core. What would I have to do to accomplish that?

Comments

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

    Before, it was using config/ruleset.xml as a default, which I do have on project level. Any idea how to make it keep using this?

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    I did not update githook module but u need the phpcs.xml at root level on project..
    config/ruleset.xml is the old one..

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

    With the same content?

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    yes..

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

    Seems to work, thx.

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

    Since spryker/git-hook is always taken from dev-master, those changes had been released. Please make sure to announce changes like this or start versioning that package.

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

    And how would you tell the console command code:sniff:style to look for phpcs.xml instead of config/ruleset.xml?

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    \Pyz\Zed\Development\DevelopmentConfig::getCodingStandard

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options
        /**
         * @return string
         */
        public function getCodingStandard(): string
        {
            return APPLICATION_ROOT_DIR . DIRECTORY_SEPARATOR . 'phpcs.xml';
        }
    
  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

    Great, thx.

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    edited September 2022
    Options

    Is there a chance to customize the pre-commit template that gets copied when running the composer script?
    Background: since we run git commit locally, PHP can not be found under

    #!/usr/bin/php

    Therefore we need something like

    #!/usr/bin/env php

    to let the system choose the location for php

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    Second: After the last update we get an error due to missing defined constant

    APPLICATION_ROOT_DIR
    

    on line 70 in CodeStyleSniffConfiguration. Anyone else? Could aslo has to do with moving to PHP8

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    Both can be solved actually by adapting the pre-commit template from

    ```

    !/usr/bin/php

    <?php

    define('PROJECT_ROOT', DIR . '/../..');
    define('PATH_PREFIX', DIRECTORY_SEPARATOR);

    require PROJECT_ROOT . '/vendor/autoload.php';

    use GitHook\Hook\SprykerPreCommit;

    $console = new SprykerPreCommit();
    $console->run();


    or so

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    yes, i made the same 1 year ago...

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    okay, but how 😄

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    i see no “hook” to replace the template that is used ^^

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    i will write u back later... ok? now in meeting