Skip to content

Commit

Permalink
Merge pull request #2 from jonathancarroll/master
Browse files Browse the repository at this point in the history
Support for >2 nested subgroups in destination path
  • Loading branch information
kreczko authored Apr 24, 2020
2 parents 1609312 + bd49402 commit f973efb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gitlab_migrate/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,18 @@ def find_group(connection, group, statistics=False):
if '/' in group:
tokens = group.split('/')
current_group = None
base_group = None
for search_for in tokens:
if current_group is None:
current_group = connection.groups.list(
search=search_for, statistics=statistics, include_subgroups=True
)[0]
base_group = current_group
else:
current_group = current_group.subgroups.list(
current_group = base_group.subgroups.list(
search=search_for, statistics=statistics, include_subgroups=True
)[0]
base_group = connection.groups.get(current_group.id)
# full API access only through groups.get
current_group = connection.groups.get(current_group.id)
return current_group
Expand All @@ -118,10 +121,10 @@ def import_project(connection, project, destination):
with open(export_file, 'rb') as f:
output = None
if type(destination).__name__ == 'User':
output = connection.projects.import_project(f, path=project.name, override=True)
output = connection.projects.import_project(f, path=project.path, override=True)
else:
output = connection.projects.import_project(
f, path=project.name, namespace=destination.id, overwrite=True,
f, path=project.path, namespace=destination.id, overwrite=True,
)
print(' >>>> Import in progress')
project_import = connection.projects.get(output['id'], lazy=True).imports.get()
Expand Down

0 comments on commit f973efb

Please sign in to comment.