Skip to content

Hooks on Windows environment #7

@iPaat

Description

@iPaat

Hi,

thanks a lot for creating and sharing this amazing package.

I got stuck with a little issue and want you to ask for assistance.
I'm running Composer on a windows box. I have installed brainmaestro/composer-git-hooks as recommended in the docs. If I run ./vendor/bin/cghooks pre-commit everything works fine and as expected. But if I want to commit via git command git commit -am 'Add feature xy.' I get an error:

error: cannot spawn .git/hooks/pre-commit: No such file or directory

Some research on this topic brought me to https://stackoverflow.com/a/20610055 with the suggestion to add the SHEBANG #!/bin/bash to the hook files. After adding this, everything works fine.

Is there a way (or could we have a way) to add this SHEBANG automatically to the hook files generated by cghooks?

My Composer file is looking as followed:

{
    "scripts": {
        "csw": [
            "phpcs --standard=ruleset_psr2_win.xml --ignore=app/Http/Controllers/Auth,app/Http/Controllers/Controller.php app/Http/Controllers"
        ],
        "cs": [
            "phpcs --standard=psr2 --ignore=app/Http/Controllers/Auth,app/Http/Controllers/Controller.php app/Http/Controllers"
        ],
        "test": [
            "phpunit --coverage-text"
        ]
    },
    "extra": {
        "hooks": {
            "pre-commit": "composer csw",
            "pre-push": "composer test"
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions