Skip to content
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

use git ignore rules to skip hooks #14

Merged
merged 1 commit into from
Apr 10, 2016
Merged

Conversation

nik-kor
Copy link
Contributor

@nik-kor nik-kor commented Feb 7, 2016

No description provided.

@tarmolov
Copy link
Owner

tarmolov commented Feb 7, 2016

Now you probably start hating me ^^

I think .githooksignore should absolutely the same as original .gitignore because git-hooks and git are tightly connected and tangled ;)

@Guria
Copy link

Guria commented Feb 8, 2016

@tarmolov +1
@nik-kor the best place to store such ignores (os, editor specific) is your global .gitttgnore

https://help.github.com/articles/ignoring-files/#create-a-global-gitignore

@nik-kor
Copy link
Contributor Author

nik-kor commented Feb 8, 2016

@tarmolov I hate you. No, just joking)

yeah, it's a good idea to use global ignore settings. Have to figure out how to extract them because they can be anywhere and I, probably, should analyze git settings

@Guria
Copy link

Guria commented Feb 8, 2016

@nik-kor why ever need to extract it. Just manage it on your own machine.

@nik-kor
Copy link
Contributor Author

nik-kor commented Feb 8, 2016

@Guria because I want to teach git-hooks to ignore some files inside git-hooks/ folders.

@Guria
Copy link

Guria commented Feb 8, 2016

Aren't githooks already ignores all that ignored by git just from its nature?

@nik-kor
Copy link
Contributor Author

nik-kor commented Feb 8, 2016

No, it isn't.)
I mean this https://github.com/tarmolov/git-hooks-js/blob/master/lib/git-hooks.js#L109 should be teached to ignore some stuff from .githooks

@tarmolov
Copy link
Owner

tarmolov commented Feb 8, 2016

Let's use git-check-ignore to check path before execution hook. It seems it'll solve the issue and you don't need to add a separate .githooksignore.

$ git check-ignore -q node_modules/.bin/mocha
$ echo $?
0
$ git check-ignore -q bin/git-hooks
$ echo $?
1

@nik-kor nik-kor force-pushed the master branch 2 times, most recently from 3b18946 to 9c2ae27 Compare February 14, 2016 18:47
@nik-kor
Copy link
Contributor Author

nik-kor commented Feb 14, 2016

have to check while it is not working in node 0.10....(

@nik-kor nik-kor changed the title .githooksignore support use git ignore rules to skip hooks Feb 14, 2016
@@ -3,6 +3,12 @@ var util = require('util');
var spawn = require('child_process').spawn;
var fs = require('fs');
var fsHelpers = require('./fs-helpers');
var execSync = require('child_process').execSync;
if (!execSync) {
execSync = require('runsync').exec;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

External modules are forbidden.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, can you explain why?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of npm@2 bug :-/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I'm dumb, but I haven't catched it yet.)
So the problem you mentioned is with postinstall npm-script?
And here we just reassign variable so polyfilling it.

You mean that this

"preinstall": "if [ $(node -e 'console.log(/0.10/.test(process.version))') = 'true' ]; then npm install runsync; else exit 0; fi"

script is buggy?

So we can just always install runsync module

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this preinstall script. Let's implement it without an external module. Async version is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we install runsync always?

I just use sync version because this test fails

  1) git-hook runner when hooks are found and a hook is unexecutable should return an error:
     AssertionError: expected [Function] to throw Error

if you think that async exec will be better than I'll rewrite the code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do love sync version but I want to support 0.8 and 0.10 as well without extra modules. Let's make async version.

excludeIgnoredPaths(hooks, function (filteredHooks) {
    runHooks(filteredHooks, [arg], callback);
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

@tarmolov
Copy link
Owner

tarmolov commented Apr 6, 2016

Just a couple of remarks and I'm ready to merge it :)

@nik-kor
Copy link
Contributor Author

nik-kor commented Apr 10, 2016

rebased it.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 95.146% when pulling 490addd on nik-kor:master into 690aff0 on tarmolov:master.

@tarmolov tarmolov merged commit cdf5c03 into tarmolov:master Apr 10, 2016
@tarmolov
Copy link
Owner

Thank you

@nik-kor
Copy link
Contributor Author

nik-kor commented Apr 10, 2016

Thank you too!
I knew some stuff doing this tiny PR)

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 this pull request may close these issues.

4 participants