Skip to content

Commit

Permalink
Project: build both default and latest version when saving the projec…
Browse files Browse the repository at this point in the history
…t form (#11177)

* Project: build both default and latest version when saving the project form

Closes #9685

* Lint

* Fix call to reverse

* Fix mock patch
  • Loading branch information
stsewd committed Mar 4, 2024
1 parent 375a408 commit b49ffc9
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 147 deletions.
16 changes: 15 additions & 1 deletion readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class ProjectTriggerBuildMixin:
"""
Mixin to trigger build on form save.
We trigger a build to the default branch and the LATEST version of the project,
since both are related, latest is an alias of the default version.
This should be replaced with signals instead of calling trigger_build
explicitly.
"""
Expand All @@ -71,7 +74,18 @@ def save(self, commit=True):
"""Trigger build on commit save."""
project = super().save(commit)
if commit:
trigger_build(project=project)
default_branch = project.versions.filter(
slug=project.get_default_branch()
).first()
if default_branch and default_branch.active:
trigger_build(project=project, version=default_branch)
latest_version = project.get_latest_version()
if (
latest_version
and latest_version != default_branch
and latest_version.active
):
trigger_build(project=project, version=latest_version)
return project


Expand Down

0 comments on commit b49ffc9

Please sign in to comment.