Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Skip promoting new stable if current stable is not machine=True #6695

Merged
merged 6 commits into from Jun 22, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions readthedocs/projects/models.py
Expand Up @@ -1068,15 +1068,21 @@ def update_stable_version(self):
Return ``None`` if no update was made or if there is no version on the
project that can be considered stable.
"""

# return immediately if the current stable is managed by the user and
# not automatically by Read the Docs (``machine=False``)
current_stable = self.get_stable_version()
if current_stable and not current_stable.machine:
return None

versions = self.versions(manager=INTERNAL).all()
new_stable = determine_stable_version(versions)
if new_stable:
current_stable = self.get_stable_version()
if current_stable:
identifier_updated = (
new_stable.identifier != current_stable.identifier
)
if identifier_updated and current_stable.machine:
humitos marked this conversation as resolved.
Show resolved Hide resolved
if identifier_updated:
log.info(
'Update stable version: %(project)s:%(version)s',
{
Expand Down
40 changes: 40 additions & 0 deletions readthedocs/rtd_tests/tests/test_project.py
Expand Up @@ -17,6 +17,7 @@
LATEST,
EXTERNAL,
)
from readthedocs.builds.constants import TAG
from readthedocs.builds.models import Build, Version
from readthedocs.oauth.services import GitHubService, GitLabService
from readthedocs.projects.constants import GITHUB_BRAND, GITLAB_BRAND
Expand Down Expand Up @@ -184,6 +185,45 @@ def test_update_stable_version_excludes_external_versions(self):
# Test that External Version is not considered for stable.
self.assertEqual(self.pip.update_stable_version(), None)

def test_update_stable_version_machine_false(self):
# Initial stable version from fixture
self.assertEqual(self.pip.update_stable_version().slug, '0.8.1')

# None, when there is no stable to promote
self.assertEqual(self.pip.update_stable_version(), None)

get(
Version,
identifier='9.0',
verbose_name='9.0',
slug='9.0',
type=TAG,
project=self.pip,
active=True,
)
# New stable now is the newly created version
self.assertEqual(self.pip.update_stable_version().slug, '9.0')

# Make stable version machine=False
stable = self.pip.get_stable_version()
stable.machine = False
stable.save()

get(
Version,
identifier='10.0',
verbose_name='10.0',
slug='10.0',
type=TAG,
project=self.pip,
active=True,
)
# None, since the stable version is marked as machine=False and Read
# the Docs does not have control over it
with patch('readthedocs.projects.models.determine_stable_version') as m:
self.assertEqual(self.pip.update_stable_version(), None)
m.assert_not_called()

def test_has_good_build_excludes_external_versions(self):
# Delete all versions excluding External Versions.
self.pip.versions.exclude(type=EXTERNAL).delete()
Expand Down