Skip to content

Expose negate and deprecate pcre hooks #404

Closed

Description

@asottile

See

negate: Make nonzero successful and zero a failure

I imagine something like this:

- id: test
  language: system
  negate_returncode: true
  entry: grep -P herp

Instead of the equivalent pcre hook

Activity

  1. Lucas-C commented on Dec 19, 2016

    @Lucas-C
    Contributor

    Relying on standard Unix system commands won't make pre-commit very Windows-friendly.

  2. asottile commented on Dec 19, 2016

    @asottile
    MemberAuthor

    That wouldn't be a regression, pcre hooks run grep -P on windows right now:

    GREP = 'ggrep' if sys.platform == 'darwin' else 'grep'

    Most of the reason I want to make pcre less special is due to the complexity maintained here and some oddities about cygwin compiled binaries (our tests for pcre are xfailed on windows despite it providing a grep binary which responds to -P and for the most part works)

  3. Lucas-C commented on Jan 2, 2017

    @Lucas-C
    Contributor

    I understand. But maybe we could emulate grep in Python ? It think that would not mean adding much code, and would be really more robust and testable.

  4. chriskuehl commented on Jan 2, 2017

    @chriskuehl
    Member

    pcre hooks are pretty powerful -- I've written a few of them (usually hooks specific to certain projects) because they're cheap and easy (and I probably wouldn't have taken the time to write them if it was harder than just an entry in .pre-commit-config.yaml). I think they're a pretty cool feature.

    Would a simple Python implementation that basically runs re.search on the file contents be enough? It's not quite pcre (so, probably a breaking change), but I think that'd be preferable to dropping regex matching entirely.

  5. asottile commented on Jan 2, 2017

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions