-
Notifications
You must be signed in to change notification settings - Fork 30
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
tmp files in hook's directory #12
Comments
It should show an error which motivated a developer to fix a file permissions or to remove bad a file. Didn't it work for you? |
Ok. The original problem was with .swp file and what I've got was
and it was fixed in 1.0.1 - it's informative now.) |
But hey. It's hard to debug hooks with vim anyway. |
Do you have any suggestions? |
diff --git a/lib/git-hooks.js b/lib/git-hooks.js
index afd6dc0..2c91347 100644
--- a/lib/git-hooks.js
+++ b/lib/git-hooks.js
@@ -4,6 +4,7 @@ var spawn = require('child_process').spawn;
var fs = require('fs');
var fsHelpers = require('./fs-helpers');
+const EXCLUDE_HOOKS_RE = /.swp$/;
var HOOKS_DIRNAME = 'hooks';
var HOOKS_OLD_DIRNAME = 'hooks.old';
var HOOKS_TEMPLATE_FILE_NAME = 'hook-template.js';
@@ -131,7 +132,13 @@ function runHooks(hooks, args, callback) {
return;
}
- var hook = spawnHook(hooks.shift(), args);
+ var hookPath = hooks.shift();
+ if (EXCLUDE_HOOKS_RE.test(hookPath)) {
+ runHooks(hooks, args, callback);
+ return;
+ }
+
+ var hook = spawnHook(hookPath, args);
hook.on('close', function (code) {
if (code === 0) {
runHooks(hooks, args, callback); |
It solves the issue only for vim but not for other editors. It seems to solve the issue we need to add some kind of '.githooksignore'. It'll increase complexity of the module but I'm not sure that this feature are really essential. |
Yeah. It sounds more general solution. пн, 1 Фев 2016, 12:17, Alexander Tarmolov [email protected]:
|
so #14 |
Hi!
I had added the git-hook and it wasn't working. The reason was *.swp file generated by vim.
I was going to create PR but saw the tests and it considered as normal case. But maybe it's a good idea to handle it somehow. E.g. add a list with exceptional extensions or analyse execute permission for the file.
What do you think?
The text was updated successfully, but these errors were encountered: