mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 04:54:16 +00:00
More naturally sort requirements.
This commit is contained in:
parent
a4ba3ca567
commit
151d485a81
2 changed files with 5 additions and 1 deletions
|
|
@ -18,7 +18,10 @@ class Requirement(object):
|
||||||
elif requirement.value == b'\n':
|
elif requirement.value == b'\n':
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return self.value < requirement.value
|
return (
|
||||||
|
self.value.partition(b'==') <
|
||||||
|
requirement.value.partition(b'==')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def fix_requirements(f):
|
def fix_requirements(f):
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ TESTS = (
|
||||||
(b'#comment\n\nbar\nfoo\n', 0, b'#comment\n\nbar\nfoo\n'),
|
(b'#comment\n\nbar\nfoo\n', 0, b'#comment\n\nbar\nfoo\n'),
|
||||||
(b'\nfoo\nbar\n', 1, b'bar\n\nfoo\n'),
|
(b'\nfoo\nbar\n', 1, b'bar\n\nfoo\n'),
|
||||||
(b'\nbar\nfoo\n', 0, b'\nbar\nfoo\n'),
|
(b'\nbar\nfoo\n', 0, b'\nbar\nfoo\n'),
|
||||||
|
(b'pyramid==1\npyramid-foo==2\n', 0, b'pyramid==1\npyramid-foo==2\n'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue