Commit f878035e authored by Henrik Skov Midtiby's avatar Henrik Skov Midtiby

skipping already created repo and assigned users

(Change by Henrik Egemose).
parent 7a65c58d
......@@ -73,9 +73,17 @@ class GitlabClassHelper:
if resp.ok:
print('Created project "%s" in "%s".' % (repo_name, group_name))
else:
print('Failed to create project "%s" in "%s".' % (repo_name, group_name))
print(resp.json()['message'])
print(url)
try:
if resp.json()['message']['name'][0] == 'has already been taken':
print('Project "%s" in "%s" as already been created. Skipping.' % (repo_name, group_name))
else:
print('Failed to create project "%s" in "%s".' % (repo_name, group_name))
raise requests.HTTPError('%s for url: %s' % (resp.json()['message'], url))
except KeyError:
print('Failed to create project "%s" in "%s".' % (repo_name, group_name))
raise requests.HTTPError('%s for url: %s' % (resp.json()['message'], url))
def get_group_name(self, group_id: int) -> str:
"""
......@@ -128,7 +136,13 @@ class GitlabClassHelper:
if resp.ok:
print('Added userid "%d" to the project "%s".' % (user_id, repo_name))
else:
print('User already exist - "%d" to the project "%s".' % (user_id, repo_name))
try:
if resp.json()['message'] == 'Member already exists':
print('User "%s" already added to repository "%s". Skipping.' % (user_id, repo_name))
else:
raise requests.HTTPError('%s for url: %s' % (resp.json()['message'], url))
except KeyError:
raise requests.HTTPError('%s for url: %s' % (resp.json()['message'], url))
def push_git_repo_to_repositories(self, local_path: str, repositories: List[str], group_id: int = None):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment