Skip to content

Commit

Permalink
fix api search utils to accept major* version (bug 629599)
Browse files Browse the repository at this point in the history
  • Loading branch information
cvan committed Feb 19, 2011
1 parent fee9465 commit 7af7a6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/search/tests/test_searchutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ def c(x, y):
return 0

v = ['1.9.0a1pre', '1.9.0a1', '1.9.1.b5', '1.9.1.b5', '1.9.1pre',
'1.9.1', '1.9.0']
'1.9.1', '1.9.0', '1.9.*', '1.9*']

eq_(c(v[0], v[1]), -1)
eq_(c(v[1], v[2]), -1)
eq_(c(v[2], v[3]), 0)
eq_(c(v[3], v[4]), -1)
eq_(c(v[4], v[5]), -1)
eq_(c(v[5], v[6]), 1)
eq_(c(v[7], v[8]), 0)
2 changes: 2 additions & 0 deletions apps/search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def convert_version(version_string):
# Replace .x or .* with .99 since these are equivalent.
version_string = version_string.replace('.x', '.99')
version_string = version_string.replace('.*', '.99')
# Replace any leftover * with .99 (e.g., 4.0* => 4.0.99).
version_string = version_string.replace('*', '.99')

# Replace \d+\+ with $1++pre0 (e.g. 2.1+ => 2.2pre0).

Expand Down

0 comments on commit 7af7a6c

Please sign in to comment.