From d4ce9c3ee39737105a334f4a613d416a846dab32 Mon Sep 17 00:00:00 2001 From: Vadim Troshchinskiy Date: Thu, 6 Feb 2025 16:22:38 +0100 Subject: [PATCH] Make branch deletion RESTful --- api/gitapi.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/api/gitapi.py b/api/gitapi.py index dc2dfc2..02e3747 100755 --- a/api/gitapi.py +++ b/api/gitapi.py @@ -543,7 +543,9 @@ class GitRepoBranches(Resource): "branches": branches } - def delete(self, repo): +@git_ns.route('/repositories//branches/') +class GitRepoBranchesDeleter(Resource): + def delete(self, repo, branch): """Delete a given branch in a given repository Args: @@ -555,19 +557,6 @@ class GitRepoBranches(Resource): - 404: A JSON object with an "error" key containing the message "Repository not found" or "Branch not found" """ - data = request.json - - if data is None: - log.error("Can't delete branch, JSON post data missing") - return {"error" : "Parameters missing"}, 400 - - if not "branch" in data: - log.error("Can't delete branch, 'branch' key in JSON data is missing") - return {"error" : "Parameters missing"}, 400 - - branch = data['branch'] - - repo_path = os.path.join(REPOSITORIES_BASE_PATH, repo + ".git") if not os.path.isdir(repo_path): log.error("Can't get branches of repository repository %s, not found. Looked in %s", repo, repo_path, extra = {"repository" : repo, "path" : repo_path }) @@ -586,9 +575,6 @@ class GitRepoBranches(Resource): return {"status": "deleted"}, 200 - - - @git_ns.route('/health') class GitHealth(Resource): def get(self):