From 063bd0c75ad00a8b2801cacf1f2fd6544566beff Mon Sep 17 00:00:00 2001 From: Vlad Glagolev Date: Thu, 27 May 2021 15:04:05 +0000 Subject: [PATCH] Auto-create non-existent repositories on SourceHut --- remirror/remirror | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/remirror/remirror b/remirror/remirror index 67ec4a7..0be8de6 100755 --- a/remirror/remirror +++ b/remirror/remirror @@ -360,7 +360,18 @@ class ProviderSourceHut(Provider): raise requests.HTTPError(500) if data.get('repositoryByOwner') is None: - raise requests.HTTPError(404) + repo_mk = {'query': 'mutation CreateRepo($name: String!, $description: String, $visibility: Visibility!) { createRepository(name: $name, description: $description, visibility: $visibility) { name } }', + 'variables': {'name': repo.name, 'visibility': 'public'.upper()}} + + req = self.http_call(graphql, repo_mk) + + req.raise_for_status() + + data = req.json()['data'] + + # empty data equals server error + if data is None or data.get('createRepository') is None: + raise requests.HTTPError(500) def mirror(conf): -- 2.45.2