wecodemore / grunt-githooks

A Grunt plugin to help bind Grunt tasks to Git hooks
https://npmjs.org/package/grunt-githooks
MIT License
317 stars 24 forks source link

grunt + githooks + magento #28

Closed klierik closed 10 years ago

klierik commented 10 years ago

Hello. Thanks you for your package.

I try create grunt environment for Magento theme. There what i have:

../path/magento/
../path/magento/.git/
../path/magento/skin/frontend/gjc/default/
../path/magento/skin/frontend/gjc/default/Gruntfile.js

Okay. I install grunt-githooks and add next code:

        /**
         * GIT Hooks
         */
        githooks: {
            options: {
                template: '<%= project.app %>/../../../../.git/hooks'
            },
            all: {
                'pre-commit': 'build',
                'post-merge': 'autoupdate githooks build'
            }
        },

i try run $ grunt githooks and i get next:

Running "githooks:all" (githooks) task

Binding `build` to `pre-commit` Git hook.
Warning: EISDIR, illegal operation on a directory Use --force to continue.

Aborted due to warnings.

Can you tell me please where is my problem?

PS: <%= project.app %> path is:

project: {
            // default project folder
            app: '.',
franz-josef-kaiser commented 10 years ago

The error

 EISDIR, illegal operation on a directory

means that your "file" is either a directory or non existent. It could also be a chmod/permission problem. But honestly with ../../../../ I don't wonder when this fails.

Btw, why are you targetting the main projects (Magento) git hooks folder? This imo is far from ideal and the opposite of portable. You could add another Gruntfile.js to your projects root to target those hooks. Or you could try to set up your front end dev folder outside the Magento root directory. You could (for e.g.) use a Virtual Machine and symlink your themes folder so it lives outside the Magento root, etc.

franz-josef-kaiser commented 10 years ago

Oh. Wait a second. After re-reading your definitions: Please read the documentation again (and then probably again).

  1. The template option should point to an actual hook template and not to your .git/hooks folder.
  2. The hooks are meant to hold Grunt task names. So 'post-merge': 'autoupdate githooks build' have to be actual tasks.
  3. Please avoid running the githook task itself. You will create an infinite loop...

Hope that helps.

klierik commented 10 years ago

The error EISDIR, illegal operation on a directory means that your "file" is either a directory or non existent. It could also be a chmod/permission problem. But honestly with ../../../../ I don't wonder when this fails. The folder is present. I check it with cd commad like:

$ cd cd ./../../../../.git/hooks/
$ ls -la
drwxr-xr-x  12 aleksej  staff   408 Jul 30 00:25 .
drwxr-xr-x  16 aleksej  staff   544 Aug  1 17:13 ..
-rw-r--r--@  1 aleksej  staff  6148 Jul 30 00:25 .DS_Store
-rwxr-xr-x   1 aleksej  staff   452 Jul 22 15:23 applypatch-msg.sample
-rwxr-xr-x   1 aleksej  staff   896 Jul 22 15:23 commit-msg.sample
-rwxr-xr-x   1 aleksej  staff   189 Jul 22 15:23 post-update.sample
-rwxr-xr-x   1 aleksej  staff   398 Jul 22 15:23 pre-applypatch.sample
-rwxr-xr-x   1 aleksej  staff  1642 Jul 22 15:23 pre-commit.sample
-rwxr-xr-x   1 aleksej  staff  1352 Jul 22 15:23 pre-push.sample
-rwxr-xr-x   1 aleksej  staff  4951 Jul 22 15:23 pre-rebase.sample
-rwxr-xr-x   1 aleksej  staff  1239 Jul 22 15:23 prepare-commit-msg.sample
-rwxr-xr-x   1 aleksej  staff  3611 Jul 22 15:23 update.sample

Btw, why are you targetting the main projects (Magento) git hooks folder? This imo is far from ideal and the opposite of portable. You could add another Gruntfile.js to your projects root to target those hooks. Or you could try to set up your front end dev folder outside the Magento root directory. You could (for e.g.) use a Virtual Machine and symlink your themes folder so it lives outside the Magento root, etc.

Because current grunt environment only for current theme. i don't need that file in Magento root. That's why i use path to .git/hooks

Oh. Wait a second. After re-reading your definitions: Please read the documentation again (and then probably again).

even if i make changes to:

        /**
         * GIT Hooks
         */
        githooks: {
            options: {
                template: '<%= project.app %>/../../../../.git/hooks'
            },
            all: {
                'pre-commit': 'build',
                'post-merge': 'autoupdate build'
            }
        },

the problem is the same :(

franz-josef-kaiser commented 10 years ago

Please read again what a template actually is. Hint: It's not in your .git/hooks folder... and hint number two: *.sample hooks won't run.

You should also decide which task should be running on which hook. There's no reason to run for e.g. build on two different hooks.

Here is a resource to help you getting started with Git Hooks.

klierik commented 10 years ago

@franz-josef-kaiser, oh, now i understand. thanks you very much for reply. i see where is my problem.

so the best way it is create githook-file manually and put it in .git/hooks folder. this will work 100% for everyone :)

franz-josef-kaiser commented 10 years ago

create githook-file manually and put it in .git/hooks folder. this will work 100% for everyone :)

True that :)