Skip to content

Adding support for locally-defined hooks - #226

Merged
asottile merged 1 commit into
pre-commit:masterfrom
Lucas-C:master
May 10, 2015
Merged

asottile merged 1 commit into
pre-commit:masterfrom
Lucas-C:master

Conversation

@Lucas-C

@Lucas-C Lucas-C commented May 10, 2015

Copy link
Copy Markdown
Contributor

Closes #219
All tests pass and coverage for new file pre_commit/hook_executor.py is 100%

Comment thread tests/commands/run_test.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

weird, there's a pre-commit hook that should split this line, does this line change when pre-commit run --all-files ? (might be a side-effect of rebase?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My bad, I hadn't install pre-commit properly on this repo ! Fixed

@Lucas-C
Lucas-C force-pushed the master branch 6 times, most recently from b43f776 to 8aa931e Compare May 10, 2015 20:45
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 99.93% when pulling 8aa931e on Lucas-C:master into d97ea30 on pre-commit:master.

2 similar comments
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 99.93% when pulling 8aa931e on Lucas-C:master into d97ea30 on pre-commit:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 99.93% when pulling 8aa931e on Lucas-C:master into d97ea30 on pre-commit:master.

Comment thread pre_commit/repository.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd just change these to raise NotImplementedError

Comment thread tests/clientlib/validate_config_test.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you can explicitly include both of those exceptions:

with pytest.raises((jsonschema.exceptions.ValidationError, InvalidConfigError)):
    # ...

@asottile

Copy link
Copy Markdown
Member

👍 Looks great, address my last couple comments and I'll merge it

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling e1098d9 on Lucas-C:master into d97ea30 on pre-commit:master.

@Lucas-C

Lucas-C commented May 10, 2015

Copy link
Copy Markdown
Contributor Author

Thanks for all your comments !
Everything should be fixed now :)

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling f5504c1 on Lucas-C:master into d97ea30 on pre-commit:master.

@Lucas-C

Lucas-C commented May 10, 2015

Copy link
Copy Markdown
Contributor Author

I guess one last thing to do will be to update the docs 😄

Comment thread pre_commit/clientlib/validate_config.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

one last thing (sorry, didn't notice this on the first passes), is there a reason to raise this error? it should just work now that we're doing it at the repository right? (it's a bit silly I agree, but it should work just fine if the check is removed?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I prefer to be strict at this early stage of config parsing, instead of allowing weird anomalies later.
E.g. if one needs a list of all the local hooks and assume there can be only one entry for them in the config.
Better avoid ambiguity, don't you think ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel that if it's not broken, why go through the extra trouble to exclude the case?

Also, since hooks run in the order they are defined, it might be desirable to run some hooks out-of-order. We currently don't forbid repeated repos at the moment so I see no reason to make local repos special in that regard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, this last argument convinced me. I'm going to remove the check.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling b68261c on Lucas-C:master into d97ea30 on pre-commit:master.

2 similar comments
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling b68261c on Lucas-C:master into d97ea30 on pre-commit:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling b68261c on Lucas-C:master into d97ea30 on pre-commit:master.

asottile added a commit that referenced this pull request May 10, 2015
Adding support for locally-defined hooks
@asottile
asottile merged commit 24ce081 into pre-commit:master May 10, 2015
@asottile

Copy link
Copy Markdown
Member

This has been released as part of 0.5.0

@asottile

asottile commented May 4, 2016

Copy link
Copy Markdown
Member

local hooks are now documented here: http://pre-commit.com/#repository-local-hooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add support for pcre / scripts / system hooks definition in .pre-commit-config.yaml

3 participants