File tree 2 files changed +23
-2
lines changed
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 11
11
from packaging .version import InvalidVersion , Version
12
12
13
13
from readthedocs .builds .constants import (
14
- LATEST_VERBOSE_NAME , STABLE_VERBOSE_NAME )
14
+ LATEST_VERBOSE_NAME , STABLE_VERBOSE_NAME , TAG )
15
15
16
16
17
17
def get_major (version ):
@@ -233,6 +233,12 @@ def determine_stable_version(version_list):
233
233
if not comparable .is_prerelease ]
234
234
235
235
if versions :
236
+ # We take preference for tags over branches. If we don't find any tag,
237
+ # we just return the first branch found.
238
+ for version_obj , comparable in versions :
239
+ if version_obj .type == TAG :
240
+ return version_obj
241
+
236
242
version_obj , comparable = versions [0 ]
237
243
return version_obj
238
244
return None
Original file line number Diff line number Diff line change @@ -95,6 +95,12 @@ def test_new_tag_update_active(self):
95
95
version_9 = Version .objects .get (slug = '0.9' )
96
96
self .assertTrue (version_9 .active )
97
97
98
+ # Version 0.9 becomes the stable version
99
+ self .assertEqual (
100
+ version_9 .identifier ,
101
+ self .pip .get_stable_version ().identifier ,
102
+ )
103
+
98
104
def test_new_tag_update_inactive (self ):
99
105
100
106
Version .objects .create (
@@ -132,8 +138,17 @@ def test_new_tag_update_inactive(self):
132
138
data = json .dumps (version_post_data ),
133
139
content_type = 'application/json' ,
134
140
)
141
+ # Version 0.9 becomes the stable version and active
135
142
version_9 = Version .objects .get (slug = '0.9' )
136
- self .assertTrue (version_9 .active is False )
143
+ self .assertEqual (
144
+ version_9 .identifier ,
145
+ self .pip .get_stable_version ().identifier ,
146
+ )
147
+ self .assertTrue (version_9 .active )
148
+
149
+ # Version 0.8.3 is still inactive
150
+ version_8 = Version .objects .get (slug = '0.8.3' )
151
+ self .assertFalse (version_8 .active )
137
152
138
153
139
154
class TestStableVersion (TestCase ):
You can’t perform that action at this time.
0 commit comments