Skip to content

Commit

Permalink
Return Bodhi update alias and URL when creating one
Browse files Browse the repository at this point in the history
  • Loading branch information
lbarcziova committed Jan 4, 2024
1 parent d1f7091 commit d9b7ca4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ def create_update(
update_notes: Optional[str] = None,
koji_builds: Optional[Sequence[str]] = None,
bugzilla_ids: Optional[list[int]] = None,
):
) -> Optional[tuple[str, str]]:
"""
Create bodhi update.
Expand All @@ -1529,12 +1529,15 @@ def create_update(
will be generated.
koji_builds: List of Koji builds or `None` (picks latest).
bugzilla_ids: List of Bugzillas that are resolved with the update.
Returns:
Alias and URL of the update or None if the update was already created.
"""
logger.debug(
f"Create bodhi update, "
f"builds={koji_builds}, dg_branch={dist_git_branch}, type={update_type}",
)
self.dg.create_bodhi_update(
return self.dg.create_bodhi_update(
koji_builds=koji_builds,
dist_git_branch=dist_git_branch,
update_notes=update_notes,
Expand Down
9 changes: 7 additions & 2 deletions packit/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def create_bodhi_update(
update_notes: Optional[str] = None,
koji_builds: Optional[Sequence[str]] = None,
bugzilla_ids: Optional[list[int]] = None,
):
) -> Optional[tuple[str, str]]:
"""
Create bodhi update.
Expand All @@ -588,6 +588,9 @@ def create_bodhi_update(
will be generated.
koji_builds: List of Koji builds or `None` (picks latest).
bugzilla_ids: List of Bugzillas that are resolved with the update.
Returns:
Alias and URL of the update or None if the update was already created.
"""
logger.debug(
f"About to create a Bodhi update of type {update_type!r} from {dist_git_branch!r}",
Expand Down Expand Up @@ -656,6 +659,8 @@ def create_bodhi_update(
for cav in result["caveats"]:
logger.info(f"- {cav['name']}: {cav['description']}\n")

return result["alias"], result["url"]

except AuthError as ex:
logger.error(ex)
raise PackitException(
Expand All @@ -668,7 +673,7 @@ def create_bodhi_update(

# early return in case update already exists
if re.match(EXISTING_BODHI_UPDATE_REGEX, str(ex)):
return
return None

raise PackitBodhiException(
f"There is a problem with creating a bodhi update:\n{ex}",
Expand Down

0 comments on commit d9b7ca4

Please sign in to comment.