Skip to content

Commit b49ffc9

Browse files
authored
Project: build both default and latest version when saving the project form (#11177)
* Project: build both default and latest version when saving the project form Closes #9685 * Lint * Fix call to reverse * Fix mock patch
1 parent 375a408 commit b49ffc9

File tree

3 files changed

+230
-147
lines changed

3 files changed

+230
-147
lines changed

readthedocs/projects/forms.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class ProjectTriggerBuildMixin:
6363
"""
6464
Mixin to trigger build on form save.
6565
66+
We trigger a build to the default branch and the LATEST version of the project,
67+
since both are related, latest is an alias of the default version.
68+
6669
This should be replaced with signals instead of calling trigger_build
6770
explicitly.
6871
"""
@@ -71,7 +74,18 @@ def save(self, commit=True):
7174
"""Trigger build on commit save."""
7275
project = super().save(commit)
7376
if commit:
74-
trigger_build(project=project)
77+
default_branch = project.versions.filter(
78+
slug=project.get_default_branch()
79+
).first()
80+
if default_branch and default_branch.active:
81+
trigger_build(project=project, version=default_branch)
82+
latest_version = project.get_latest_version()
83+
if (
84+
latest_version
85+
and latest_version != default_branch
86+
and latest_version.active
87+
):
88+
trigger_build(project=project, version=latest_version)
7589
return project
7690

7791

0 commit comments

Comments
 (0)