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
merged 2 commits into from Apr 5, 2017
Merged

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.

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.

None yet

3 participants