Skip to content

Conversation

@ghickman
Copy link
Contributor

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)
Copy link

Choose a reason for hiding this comment

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

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.
@cpburnz
Copy link
Owner

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 patch-1 branch April 5, 2017 05:51
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.

3 participants