Skip to content

Hooks on Windows environment #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iPaat opened this issue Jul 24, 2017 · 2 comments · Fixed by #8
Closed

Hooks on Windows environment #7

iPaat opened this issue Jul 24, 2017 · 2 comments · Fixed by #8

Comments

@iPaat
Copy link
Contributor

iPaat commented Jul 24, 2017

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"
        }
    }
}
@BrainMaestro
Copy link
Owner

Hey @SuNflOw1991, glad to hear that you like the project. I didn't test on Windows, so the issue didn't come up. But sure, I'll fix it.

You are welcome to try. How I would do it is by checking the OS before creating the hook files and adding the SHEBANG if we're in Windows.

@iPaat
Copy link
Contributor Author

iPaat commented Jul 24, 2017

Thanks a lot, I very appreciate your efforts.

The proposed solution sounds good to me. I'll try it as soon as the update is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants