Skip to content

Commit 03541e2

Browse files
authored
Merge pull request #6695 from readthedocs/humitos/skip-stable-if-not-machine
2 parents f3cdffb + 5dfcd37 commit 03541e2

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

readthedocs/projects/models.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1066,15 +1066,21 @@ def update_stable_version(self):
10661066
Return ``None`` if no update was made or if there is no version on the
10671067
project that can be considered stable.
10681068
"""
1069+
1070+
# return immediately if the current stable is managed by the user and
1071+
# not automatically by Read the Docs (``machine=False``)
1072+
current_stable = self.get_stable_version()
1073+
if current_stable and not current_stable.machine:
1074+
return None
1075+
10691076
versions = self.versions(manager=INTERNAL).all()
10701077
new_stable = determine_stable_version(versions)
10711078
if new_stable:
1072-
current_stable = self.get_stable_version()
10731079
if current_stable:
10741080
identifier_updated = (
10751081
new_stable.identifier != current_stable.identifier
10761082
)
1077-
if identifier_updated and current_stable.machine:
1083+
if identifier_updated:
10781084
log.info(
10791085
'Update stable version: %(project)s:%(version)s',
10801086
{

readthedocs/rtd_tests/tests/test_project.py

+40
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
LATEST,
1818
EXTERNAL,
1919
)
20+
from readthedocs.builds.constants import TAG
2021
from readthedocs.builds.models import Build, Version
2122
from readthedocs.oauth.services import GitHubService, GitLabService
2223
from readthedocs.projects.constants import GITHUB_BRAND, GITLAB_BRAND
@@ -184,6 +185,45 @@ def test_update_stable_version_excludes_external_versions(self):
184185
# Test that External Version is not considered for stable.
185186
self.assertEqual(self.pip.update_stable_version(), None)
186187

188+
def test_update_stable_version_machine_false(self):
189+
# Initial stable version from fixture
190+
self.assertEqual(self.pip.update_stable_version().slug, '0.8.1')
191+
192+
# None, when there is no stable to promote
193+
self.assertEqual(self.pip.update_stable_version(), None)
194+
195+
get(
196+
Version,
197+
identifier='9.0',
198+
verbose_name='9.0',
199+
slug='9.0',
200+
type=TAG,
201+
project=self.pip,
202+
active=True,
203+
)
204+
# New stable now is the newly created version
205+
self.assertEqual(self.pip.update_stable_version().slug, '9.0')
206+
207+
# Make stable version machine=False
208+
stable = self.pip.get_stable_version()
209+
stable.machine = False
210+
stable.save()
211+
212+
get(
213+
Version,
214+
identifier='10.0',
215+
verbose_name='10.0',
216+
slug='10.0',
217+
type=TAG,
218+
project=self.pip,
219+
active=True,
220+
)
221+
# None, since the stable version is marked as machine=False and Read
222+
# the Docs does not have control over it
223+
with patch('readthedocs.projects.models.determine_stable_version') as m:
224+
self.assertEqual(self.pip.update_stable_version(), None)
225+
m.assert_not_called()
226+
187227
def test_has_good_build_excludes_external_versions(self):
188228
# Delete all versions excluding External Versions.
189229
self.pip.versions.exclude(type=EXTERNAL).delete()

0 commit comments

Comments
 (0)