Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

handle versions with leading zeros, fixes #39 #42

Merged
merged 1 commit into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ put it directly into ``pip``.
Version History
===============

0.11.0
* Cope with leading zeros in version numbers when figuring out what
the latest version is.
See https://github.com/peterbe/hashin/issues/39

0.10.0
* Latest version is now figured out by looking at all version numbers
in the list of releases from the JSON payload. The pre releases are
Expand Down
4 changes: 2 additions & 2 deletions hashin.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ def get_latest_version(data):
for version in data['releases']:
v = parse(version)
if not v.is_prerelease:
all_versions.append(v)
all_versions.append((v, version))
all_versions.sort(reverse=True)
# return the highest non-pre-release version
return str(all_versions[0])
return str(all_versions[0][1])


def expand_python_version(version):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name='hashin',
version='0.10.0',
version='0.11.0',
description='Edits your requirements.txt by hashing them in',
long_description=open(path.join(_here, 'README.rst')).read(),
author='Peter Bengtsson',
Expand Down
14 changes: 14 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ def test_get_latest_version_non_pre_release(self, murlopen):
})
self.assertEqual(version, '0.999')

@mock.patch('hashin.urlopen')
def test_get_latest_version_non_pre_release_leading_zeros(self, murlopen):
version = hashin.get_latest_version({
'info': {
'version': '0.3',
},
'releases': {
'0.04.13': {},
'0.04.21': {},
'0.04.09': {},
}
})
self.assertEqual(version, '0.04.21')

@mock.patch('hashin.urlopen')
def test_get_hashes_error(self, murlopen):

Expand Down