Skip to content

Commit

Permalink
Fix bug + logging
Browse files Browse the repository at this point in the history
  • Loading branch information
thegreyd committed Jul 3, 2023
1 parent 72015cb commit c92b0a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion elliottlib/cli/move_builds_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"--noop", "--dry-run",
is_flag=True, default=False,
help="Don't change anything")
def move_builds_cli(from_advisory, to_advisory, kind, only, noop):
@click.pass_obj
def move_builds_cli(runtime, from_advisory, to_advisory, kind, only, noop):
"""
Move attached builds from one advisory to another.
Default is moving all attached builds. Specify builds using --only.
Expand All @@ -38,19 +39,23 @@ def move_builds_cli(from_advisory, to_advisory, kind, only, noop):
$ elliott move-builds --from 123 --to 456 -k image --only nvr1,nvr2
"""

runtime.initialize(no_group=True)
ensure_erratatool_auth()

LOGGER.info(f'Fetching all builds from {from_advisory}')
attached_builds = errata.get_brew_builds(from_advisory)
build_nvrs = [b.nvr for b in attached_builds]

if only:
LOGGER.info(f'Filtering to only specified builds')
only_nvrs = []
for n in only.split(','):
if n not in build_nvrs:
LOGGER.warning(f"{n} not found attached to advisory {from_advisory}")
else:
only_nvrs.append(n)
build_nvrs = only_nvrs
attached_builds = [b for b in attached_builds if b.nvr in build_nvrs]

if noop:
LOGGER.info(f"[DRY-RUN] Would've removed {len(attached_builds)} builds from {from_advisory} and added to"
Expand Down

0 comments on commit c92b0a5

Please sign in to comment.