From: Michael Tremer Date: Fri, 24 Jan 2025 11:06:48 +0000 (+0000) Subject: builds: Rename "build_repo" to just "repo" X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6ae91b327a65f3012cdb2cfc5e72e8891b193ad;p=pbs.git builds: Rename "build_repo" to just "repo" Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index 67eec6f7..31d453ed 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -267,7 +267,7 @@ class Builds(base.Object): # Insert the build into the database build = await self.db.insert( Build, - build_repo = repo, + repo = repo, pkg = package, owner = owner, build_group_id = group.id if group else None, @@ -447,19 +447,19 @@ class Build(database.Base, database.BackendMixin, database.SoftDeleteMixin): owner = sqlalchemy.orm.relationship("User", foreign_keys=[owner_id], lazy="joined") - # Build Repo ID + # Repo ID - build_repo_id = Column(Integer, ForeignKey("repositories.id"), nullable=False) + repo_id = Column(Integer, ForeignKey("repositories.id"), nullable=False) - # Build Repo + # Repo - build_repo = sqlalchemy.orm.relationship("Repo", lazy="selectin") + repo = sqlalchemy.orm.relationship("Repo", lazy="selectin") # Distro @functools.cached_property def distro(self): - return self.build_repo.distro + return self.repo.distro # Group ID @@ -800,7 +800,7 @@ class Build(database.Base, database.BackendMixin, database.SoftDeleteMixin): """ # Remaster the build repository? if build: - await self.build_repo.changed() + await self.repo.changed() # Remaster all other repositories for repo in self.repos: @@ -968,7 +968,7 @@ class Build(database.Base, database.BackendMixin, database.SoftDeleteMixin): AND other_builds.pkg_id = other_packages.id AND - other_builds.build_repo_id = builds.build_repo_id + other_builds.repo_id = builds.repo_id -- Start with this build WHERE @@ -1137,7 +1137,7 @@ class Build(database.Base, database.BackendMixin, database.SoftDeleteMixin): # Launch test build t = await self.backend.builds.create( # Use the same build repository - repo=self.build_repo, + repo=self.repo, package=build.pkg, owner=self.owner, group=group, @@ -1188,6 +1188,10 @@ class Build(database.Base, database.BackendMixin, database.SoftDeleteMixin): """ Creates a clone of this build """ + # Clone into the same repository if none given + if repo is None: + repo = self.repo + # Create a new build from the same package clone = await self.backend.builds.create( # Build the same package @@ -1197,7 +1201,7 @@ class Build(database.Base, database.BackendMixin, database.SoftDeleteMixin): owner = owner, # Repository - repo = repo or self.build_repo, + repo = repo, ) log.info("Cloned %s as %s" % (self, clone)) diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index e878435f..869e1715 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -128,9 +128,9 @@ class Jobs(base.Object): # Group jobs by their build repository for job in jobs: try: - repos[job.build.build_repo].append(job) + repos[job.build.repo].append(job) except KeyError: - repos[job.build.build_repo] = [job] + repos[job.build.repo] = [job] # Run the dependency check for all jobs for repo, jobs in repos.items(): @@ -1095,13 +1095,13 @@ class Job(database.Base, database.BackendMixin, database.SoftDeleteMixin): """ Generate the Pakfire configuration for this job """ - return self.build.build_repo.pakfire(arch=self.arch, **kwargs) + return self.build.repo.pakfire(arch=self.arch, **kwargs) async def installcheck(self): """ Perform install check """ - await self.build.build_repo.installcheck([self]) + await self.build.repo.installcheck([self]) # Return whether the check succeeded or not return self.installcheck_succeeded diff --git a/src/buildservice/repos.py b/src/buildservice/repos.py index dd04bb4e..e8b29fef 100644 --- a/src/buildservice/repos.py +++ b/src/buildservice/repos.py @@ -676,7 +676,7 @@ class Repo(database.Base, database.BackendMixin, database.SoftDeleteMixin): jobs ON builds.id = jobs.build_id -- Only from this repository WHERE - builds.build_repo_id = %s + builds.repo_id = %s -- Builds must not be deleted AND builds.deleted_at IS NULL diff --git a/src/database.sql b/src/database.sql index 444da994..12c761b8 100644 --- a/src/database.sql +++ b/src/database.sql @@ -240,7 +240,7 @@ CREATE TABLE public.builds ( pkg_id integer NOT NULL, severity text, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - build_repo_id integer NOT NULL, + repo_id integer NOT NULL, owner_id integer, priority integer DEFAULT 0 NOT NULL, finished_at timestamp without time zone, @@ -2052,14 +2052,6 @@ ALTER TABLE ONLY public.builds ADD CONSTRAINT builds_build_group_id FOREIGN KEY (build_group_id) REFERENCES public.build_groups(id); --- --- Name: builds builds_build_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.builds - ADD CONSTRAINT builds_build_repo_id FOREIGN KEY (build_repo_id) REFERENCES public.repositories(id); - - -- -- Name: build_comments builds_comments_build_id; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -2124,6 +2116,14 @@ ALTER TABLE ONLY public.builds ADD CONSTRAINT builds_pkg_id FOREIGN KEY (pkg_id) REFERENCES public.packages(id); +-- +-- Name: builds builds_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.builds + ADD CONSTRAINT builds_repo_id FOREIGN KEY (repo_id) REFERENCES public.repositories(id); + + -- -- Name: job_packages job_packages_job_id; Type: FK CONSTRAINT; Schema: public; Owner: - --