Skip to content

Commit

Permalink
dgroup#47: Add 400 response code when no tasks in Worksection
Browse files Browse the repository at this point in the history
  • Loading branch information
danbond02 committed Feb 13, 2022
1 parent e6f1445 commit 56d4703
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions g2w/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging

import uvicorn # pragma: no cover
from fastapi import Request, FastAPI
from fastapi import Request, FastAPI, Response, status
from fastapi.routing import APIRouter

from g2w import Push, Ws, LoggableRoute, Alert, Log, __version__
Expand All @@ -21,12 +21,14 @@
path="/gitlab/push/{project_id}",
summary="Create a comment in worksection task from Gitlab push event",
)
def push(event: Push, project_id: int) -> dict:
def push(event: Push, project_id: int, response: Response) -> dict:
log.debug("Got push event '%s' for project '%d'", event, project_id)
author = ws.find_user(event.user_email)
msg = event.comment(author)
comments = []
# @todo #/DEV Return 400 if no WS tasks found within commit messages
if not event.tasks():
response.status_code = status.HTTP_400_BAD_REQUEST
for task_id in event.tasks():
comments.append(ws.add_comment(project_id, task_id, msg))
log.debug("Added comments %s", comments)
Expand Down

0 comments on commit 56d4703

Please sign in to comment.