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

Add equality method to PathSpec #13

merged 2 commits into from Apr 5, 2017


Copy link

ghickman commented Mar 27, 2017

This adds the __eq__ method so you can compare two PathSpec instances for equality.

Personally I want this to see if a PathSpec instance has been instantiated with a default gitignore but I'm sure it would be useful to others too :)

Tests equality of this ``PathSpec`` with ``other`` based on the
regexs contained in their ``patterns``.
paired_patterns = zip(self.patterns, other.patterns)

This comment has been minimized.

Copy link

nvie Mar 27, 2017

You might need to use zip_longest() here to avoid equality when one is a "prefix" of the other.

This catches the case where one PathSpac's patterns are a subset of another which would cause a false positive when comparing them.

This comment has been minimized.

Copy link

cpburnz commented Mar 28, 2017

Thanks, I'll look over this tonight.

@cpburnz cpburnz merged commit 78ad596 into cpburnz:master Apr 5, 2017
@ghickman ghickman deleted the ghickman:patch-1 branch Apr 5, 2017
@pyup-bot pyup-bot mentioned this pull request Sep 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.