Skip to content

Commit

Permalink
frontend: use after/with-build-id fields when "rebuilding all"
Browse files Browse the repository at this point in the history
  • Loading branch information
praiskup committed Feb 18, 2025
1 parent 6ecc067 commit 081dd6a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
25 changes: 19 additions & 6 deletions frontend/coprs_frontend/coprs/logic/builds_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,11 +798,19 @@ def create_new(cls, user, copr, source_type, source_json, chroot_names=None, pkg
return build

@classmethod
def _setup_batch(cls, batch, after_build_id, with_build_id, user):
# those three are exclusive!
if sum([bool(x) for x in
[batch, with_build_id, after_build_id]]) > 1:
raise BadRequest("Multiple build batch specifiers")
def setup_batch(cls, after_build_id, with_build_id, user,
always_create=False):
"""
According to "after_build_id" and "with_build_id" arguments (they are
mutually exclusive), get a pre-existing (or create a new) batch and
return it. If neither of those args is specified, None is returned,
unless always_create=True - then a completely separate batch is crated
and returned.
"""
batch = None
if bool(with_build_id) and bool(after_build_id):
raise BadRequest("You may either build after build ID, or with "
"build id, not both.")

if with_build_id:
batch = BatchesLogic.get_batch_or_create(with_build_id, user, True)
Expand All @@ -813,6 +821,10 @@ def _setup_batch(cls, batch, after_build_id, with_build_id, user):
batch.blocked_by = old_batch
db.session.add(batch)

if always_create and batch is None:
batch = models.Batch()
db.session.add(batch)

return batch

@classmethod
Expand Down Expand Up @@ -898,7 +910,8 @@ def add(cls, user, pkgs, copr, source_type=None, source_json=None,
user, copr,
"You don't have permissions to build in this copr.")

batch = cls._setup_batch(batch, after_build_id, with_build_id, user)
if not batch:
batch = cls.setup_batch(after_build_id, with_build_id, user)

if not repos:
repos = copr.repos
Expand Down
11 changes: 6 additions & 5 deletions frontend/coprs_frontend/coprs/logic/packages_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,13 @@ def build_package(cls, user, copr, package, chroot_names=None, copr_dirname=None

@classmethod
def batch_build(cls, user, copr, packages, chroot_names=None,
only_package_chroots=None, **build_options):
new_builds = []

batch = models.Batch()
db.session.add(batch)
only_package_chroots=None, with_build_id=None,
after_build_id=None, **build_options):

new_builds = []
batch = builds_logic.BuildsLogic.setup_batch(after_build_id,
with_build_id, user,
always_create=True)
for package in packages:
git_hashes = {}
skip_import = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def copr_rebuild_all_packages(copr):
form.selected_chroots,
enable_net=form.enable_net.data,
only_package_chroots=form.only_package_chroots.data,
with_build_id=form.with_build_id.data,
after_build_id=form.after_build_id.data,
)

except (ObjectNotFound, ActionInProgressException, NoPackageSourceException, \
Expand Down

0 comments on commit 081dd6a

Please sign in to comment.