Skip to content

Commit

Permalink
Process fedmsg PR events (#115)
Browse files Browse the repository at this point in the history
Process fedmsg PR events

Related to packit/packit-service#2579

Reviewed-by: Nikola Forró
  • Loading branch information
softwarefactory-project-zuul[bot] authored Oct 24, 2024
2 parents 7e5c5c2 + 6dfad65 commit bff2924
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packit_service_fedmsg/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,33 @@ def _fedora_dg_push(topic: str, event: dict, packit_user: str) -> CallbackResult
return CallbackResult(msg=f"[Fedora DG] Passing push: {what}")


def _fedora_dg_pr_new(topic: str, event: dict, packit_user: str) -> CallbackResult:
return CallbackResult(
msg=(
f"[Fedora DG] PR #{nested_get(event, 'pullrequest', 'id')} opened in "
f"{nested_get(event, 'pullrequest', 'project', 'fullname')}"
),
)


def _fedora_dg_pr_updated(topic: str, event: dict, packit_user: str) -> CallbackResult:
return CallbackResult(
msg=(
f"[Fedora DG] PR #{nested_get(event, 'pullrequest', 'id')} updated in "
f"{nested_get(event, 'pullrequest', 'project', 'fullname')}"
),
)


def _fedora_dg_pr_rebased(topic: str, event: dict, packit_user: str) -> CallbackResult:
return CallbackResult(
msg=(
f"[Fedora DG] PR #{nested_get(event, 'pullrequest', 'id')} rebased in "
f"{nested_get(event, 'pullrequest', 'project', 'fullname')}"
),
)


def _fedora_dg_pr_flag(topic: str, event: dict, packit_user: str) -> CallbackResult:
if nested_get(event, "pullrequest", "user", "name") != packit_user:
return CallbackResult(
Expand Down Expand Up @@ -209,6 +236,9 @@ def _openscanhub_task_started(
"org.fedoraproject.prod.buildsys.build.state.change": _koji,
"org.fedoraproject.prod.buildsys.tag": _koji,
"org.fedoraproject.prod.pagure.git.receive": _fedora_dg_push,
"org.fedoraproject.prod.pagure.pull-request.new": _fedora_dg_pr_new,
"org.fedoraproject.prod.pagure.pull-request.updated": _fedora_dg_pr_updated,
"org.fedoraproject.prod.pagure.pull-request.rebased": _fedora_dg_pr_rebased,
"org.fedoraproject.prod.pagure.pull-request.flag.added": _fedora_dg_pr_flag,
"org.fedoraproject.prod.pagure.pull-request.flag.updated": _fedora_dg_pr_flag,
"org.fedoraproject.prod.pagure.pull-request.comment.added": _fedora_dg_pr_comment,
Expand Down

0 comments on commit bff2924

Please sign in to comment.