From 95f9f1e5399cef6808abdcf7fd63c6557794c51e Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Thu, 17 Feb 2022 09:35:35 -0500 Subject: [PATCH] gitsrht/blueprints/api: Accept lowercase visibility Fixes: https://todo.sr.ht/~sircmpwn/git.sr.ht/361 --- gitsrht/blueprints/api/info.py | 2 ++ gitsrht/repos.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/gitsrht/blueprints/api/info.py b/gitsrht/blueprints/api/info.py index 442acfa..cb03bd6 100644 --- a/gitsrht/blueprints/api/info.py +++ b/gitsrht/blueprints/api/info.py @@ -40,6 +40,8 @@ def repos_POST(): resp = current_app.repo_api.create_repo(valid, user) if not valid.ok: return valid.response + # Convert visibility back to lowercase + resp["visibility"] = resp["visibility"].lower() return resp, 201 @info.route("/api/repos/", defaults={"username": None}) diff --git a/gitsrht/repos.py b/gitsrht/repos.py index ded586c..56628bc 100644 --- a/gitsrht/repos.py +++ b/gitsrht/repos.py @@ -91,6 +91,11 @@ class GitRepoApi(): if not valid.ok: return None + # Convert the visibility to uppercase. This is needed for the REST API + # TODO: Remove this when the REST API is phased out + if visibility is not None: + visibility = visibility.upper() + resp = exec_gql("git.sr.ht", """ mutation CreateRepository( $name: String!, -- 2.38.4