enable deletion of repos as well

This commit is contained in:
stupidcomputer 2024-10-09 06:44:24 -05:00
parent 67314c71cf
commit 82ce1c7f6d
2 changed files with 42 additions and 33 deletions

View File

@ -47,9 +47,7 @@ def gitea_handle_repo_action():
except KeyError:
abort(400) # the data isn't formatted correctly
if not repo_action == "created":
return ''
if repo_action == "created":
new_repo = github.create_repo(
repo_name, repo_description
)
@ -82,6 +80,9 @@ def gitea_handle_repo_action():
)
return ''
elif repo_action == "deleted":
github.delete_repo(repo_owner, repo_name)
@app.route("/bridge/endpoints/gitea/issue", methods=["POST"])
def gitea_handle_issue_action():

View File

@ -43,6 +43,9 @@ class WebgitClient:
def patch(self, *args, **kwargs):
return self._request_wrapper("PATCH", *args, **kwargs)
def delete(self, *args, **kwargs):
return self._request_wrapper("DELETE", *args, **kwargs)
def create_repo(self, name, description):
return self.post(
self.api_prefix + "/user/repos",
@ -104,6 +107,11 @@ class WebgitClient:
},
)
def delete_repo(self, owner, repo_name):
return self.delete(
self.api_prefix + "/repos/{}/{}".format(owner, repo_name)
)
@dataclass
class Github(WebgitClient):
"""