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

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

    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 Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    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

    With the same content?

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    yes..

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    Seems to work, thx.

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    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

    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 Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    \Pyz\Zed\Development\DevelopmentConfig::getCodingStandard

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet
        /**
         * @return string
         */
        public function getCodingStandard(): string
        {
            return APPLICATION_ROOT_DIR . DIRECTORY_SEPARATOR . 'phpcs.xml';
        }
    
  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    Great, thx.

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited September 2022

    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

    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

    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 Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

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

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 πŸ§‘πŸ»β€πŸš€ - Cadet

    okay, but how πŸ˜„

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 πŸ§‘πŸ»β€πŸš€ - Cadet

    i see no β€œhook” to replace the template that is used ^^

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

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