From ca5dc87e824dedc00ba06d67f524e7c8cdcd1666 Mon Sep 17 00:00:00 2001 From: drunkendog Date: Mon, 25 Sep 2023 20:57:21 +0100 Subject: [PATCH] Fix bug with if statements --- api.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/api.py b/api.py index d97d34c..364b057 100644 --- a/api.py +++ b/api.py @@ -49,14 +49,9 @@ async def set_badge(repo: str, new_badge: str, branch: str=None, action: str=Non @app.get("/get_badge/") async def get_badge(repo: str, branch: str=None, action: str=None): - if branch is None and action is None and repo not in badge_dict.keys(): + if (repo, branch, action) not in badge_dict.keys() or repo not in badge_dict.keys(): raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, - detail="Repo not found", - ) - elif (repo, branch, action) not in badge_dict.keys(): - raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, - detail="Repo not found", + detail="Badge not found", ) return RedirectResponse("https://img.shields.io/badge/" + (badge_dict[repo, branch, action] if branch is not None or action is not None else badge_dict[repo]))