Skip to content

Commit 0cfa2d6

Browse files
authored
Revert "Build: use tag name for checkout (#10879)"
This reverts commit 42a82ca.
1 parent fe7e976 commit 0cfa2d6

File tree

2 files changed

+4
-79
lines changed

2 files changed

+4
-79
lines changed

readthedocs/doc_builder/director.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,7 @@ def checkout(self):
225225
log.info("Cloning and fetching.")
226226
self.vcs_repository.update()
227227

228-
# NOTE: we use `commit_name` instead of `identifier`,
229-
# since identifier can be a ref name or a commit hash,
230-
# and we want to use the ref name when doing the checkout when possible
231-
# (e.g. `main` instead of `a1b2c3d4`, or `v1.0` instead of `a1b2c3d4`).
232-
# See https://github.com/readthedocs/readthedocs.org/issues/10838.
233-
identifier = self.data.build_commit or self.data.version.commit_name
228+
identifier = self.data.build_commit or self.data.version.identifier
234229
log.info("Checking out.", identifier=identifier)
235230
self.vcs_repository.checkout(identifier)
236231

readthedocs/projects/tests/test_build_tasks.py

+3-73
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
BUILD_STATUS_FAILURE,
1212
BUILD_STATUS_SUCCESS,
1313
EXTERNAL,
14-
TAG,
1514
)
1615
from readthedocs.builds.models import Build
1716
from readthedocs.config import ALL, ConfigError
@@ -22,7 +21,6 @@
2221
from readthedocs.projects.models import EnvironmentVariable, Project, WebHookEvent
2322
from readthedocs.projects.tasks.builds import sync_repository_task, update_docs_task
2423
from readthedocs.telemetry.models import BuildData
25-
from readthedocs.vcs_support.backends.git import Backend
2624

2725
from .mockers import BuildEnvironmentMocker
2826

@@ -62,19 +60,17 @@ def _get_project(self):
6260
return fixture.get(
6361
Project,
6462
slug="project",
65-
repo="https://github.com/readthedocs/readthedocs.org",
6663
enable_epub_build=True,
6764
enable_pdf_build=True,
6865
)
6966

70-
def _trigger_update_docs_task(self, **kwargs):
67+
def _trigger_update_docs_task(self):
7168
# NOTE: is it possible to replace calling this directly by `trigger_build` instead? :)
72-
kwargs.setdefault("build_api_key", "1234")
73-
kwargs.setdefault("build_commit", self.build.commit)
7469
return update_docs_task.delay(
7570
self.version.pk,
7671
self.build.pk,
77-
**kwargs,
72+
build_api_key="1234",
73+
build_commit=self.build.commit,
7874
)
7975

8076
class TestCustomConfigFile(BuildEnvironmentBase):
@@ -694,72 +690,6 @@ def test_failed_build(
694690
assert revoke_key_request._request.method == "POST"
695691
assert revoke_key_request.path == "/api/v2/revoke/"
696692

697-
@mock.patch.object(Backend, "ref_exists")
698-
@mock.patch("readthedocs.doc_builder.director.load_yaml_config")
699-
def test_checkout_tag_by_name(self, load_yaml_config, ref_exists):
700-
ref_exists.return_value = False
701-
self.version.type = TAG
702-
self.version.identifier = "abc123"
703-
self.version.verbose_name = "v1.0"
704-
self.version.slug = "v1.0"
705-
self.machine = False
706-
self.version.save()
707-
load_yaml_config.return_value = get_build_config({})
708-
709-
self._trigger_update_docs_task(build_commit=None)
710-
711-
self.mocker.mocks["git.Backend.run"].assert_has_calls(
712-
[
713-
mock.call("git", "clone", "--depth", "1", mock.ANY, "."),
714-
mock.call(
715-
"git",
716-
"fetch",
717-
"origin",
718-
"--force",
719-
"--prune",
720-
"--prune-tags",
721-
"--depth",
722-
"50",
723-
"refs/tags/v1.0:refs/tags/v1.0",
724-
),
725-
mock.call("git", "checkout", "--force", "v1.0"),
726-
mock.call("git", "clean", "-d", "-f", "-f"),
727-
]
728-
)
729-
730-
@mock.patch.object(Backend, "ref_exists")
731-
@mock.patch("readthedocs.doc_builder.director.load_yaml_config")
732-
def test_checkout_external_version_by_commit(self, load_yaml_config, ref_exists):
733-
ref_exists.return_value = False
734-
self.version.type = EXTERNAL
735-
self.version.identifier = "abc123"
736-
self.version.verbose_name = "22"
737-
self.version.slug = "22"
738-
self.machine = False
739-
self.version.save()
740-
load_yaml_config.return_value = get_build_config({})
741-
742-
self._trigger_update_docs_task(build_commit=None)
743-
744-
self.mocker.mocks["git.Backend.run"].assert_has_calls(
745-
[
746-
mock.call("git", "clone", "--depth", "1", mock.ANY, "."),
747-
mock.call(
748-
"git",
749-
"fetch",
750-
"origin",
751-
"--force",
752-
"--prune",
753-
"--prune-tags",
754-
"--depth",
755-
"50",
756-
"pull/22/head:external-22",
757-
),
758-
mock.call("git", "checkout", "--force", "abc123"),
759-
mock.call("git", "clean", "-d", "-f", "-f"),
760-
]
761-
)
762-
763693
@mock.patch("readthedocs.doc_builder.director.load_yaml_config")
764694
def test_build_commands_executed(
765695
self,

0 commit comments

Comments
 (0)