Open CamdenSegal opened 10 years ago
@CamdenSegal Could you elaborate this with an additional PR for the current template?
I guess I got your problem: You have some task running in your git hook/file that requires the Gruntfile. Please remove that. In case I misunderstood you, please simply add your file and explain what you are doing (in code). We can then reopen that issue.
As it stands the hook files just try to run grunt with the tasks given at the time of running grunt githooks
.
Let's say you have a three branches in your repo:
If you were to run grunt githooks
while in branch 1, then switch to branch 2 and try to commit it will fail and not allow you to commit because it will try to run the non-existant qunit task, and will not run the proper clean pre-commit task for this branch.
If you were to run grunt githooks
on either branch 1 or 2 and then switch to branch 3 it would fail to commit because the attempt to run any grunt task would fail without a Gruntfile.js.
My proposed solution is to include a check for the existance of the Gruntfile.js before any hook tasks are run, then to run something like grunt githooks:pre-commit
which will run the task currently assigned to that git hook. This solution could bind to every git hook at the start and never need to be rebound if the tasks or branches ever change.
Does that make sense? Is there a better way to approach this issue? If you think that is a worthwhile change I can work on a PR.
Does that make sense?
Yes, it perfectly makes sense.
Is there a better way to approach this issue? If you think that is a worthwhile change I can work on a PR.
:+1: Thank you in advance!
I've setup a pre-commit hook using grunt-githooks on a branch of my repository. If I switch to a branch that is not configured with a gruntfile it blocks me from committing with the error "Fatal error: Unable to find Gruntfile."
It seems like it could be a good practice change the hook script from binding into specific grunt tasks to instead:
This will allow for changing the tasks to be run per hook by just modifying the gruntfile, and also allow for different tasks, or no tasks, to be run on different branches.