Fix group search

This commit is contained in:
rtm516 2020-05-28 19:35:45 +01:00
parent b1c187ec44
commit 933627610a

View File

@ -134,13 +134,17 @@ def get_collaborators(gitea_api: pygitea, owner: string, repo: string) -> []:
return existing_collaborators return existing_collaborators
def get_user_or_group(gitea_api: pygitea, name: string) -> {}: def get_user_or_group(gitea_api: pygitea, project: gitlab.v4.objects.Project) -> {}:
result = None result = None
response: requests.Response = gitea_api.get("/users/" + name) response: requests.Response = gitea_api.get("/users/" + project.namespace['path'])
if response.ok: if response.ok:
result = response.json() result = response.json()
else: else:
print_error("Failed to load user or group " + name + "! " + response.text) response: requests.Response = gitea_api.get("/orgs/" + name_clean(project.namespace["name"]))
if response.ok:
result = response.json()
else:
print_error("Failed to load user or group " + project.namespace["name"] + "! " + response.text)
return result return result
@ -382,7 +386,7 @@ def _import_project_repo(gitea_api: pygitea, project: gitlab.v4.objects.Project)
private = project.visibility == 'private' or project.visibility == 'internal' private = project.visibility == 'private' or project.visibility == 'internal'
# Load the owner (users and groups can both be fetched using the /users/ endpoint) # Load the owner (users and groups can both be fetched using the /users/ endpoint)
owner = get_user_or_group(gitea_api, project.namespace['name']) owner = get_user_or_group(gitea_api, project)
if owner: if owner:
import_response: requests.Response = gitea_api.post("/repos/migrate", json={ import_response: requests.Response = gitea_api.post("/repos/migrate", json={
"auth_password": GITLAB_ADMIN_PASS, "auth_password": GITLAB_ADMIN_PASS,