Loading gitlab_butler/butler.py +2 −2 Original line number Diff line number Diff line Loading @@ -446,7 +446,7 @@ class Butler: print(f"🏢 Group {AnsiColors.BLUE}{group.full_path}{AnsiColors.RESET}...") # 2: clean subprojects subprojects = group.projects.list(all=True) subprojects = group.projects.list(all=True, order_by="path", sort="asc") if len(subprojects) > 0: print(f"- clean {len(subprojects)} sub projects...") for project in subprojects: Loading @@ -470,7 +470,7 @@ class Butler: # 3: clean subgroups if not self.skip_subgroups: subgroups = group.descendant_groups.list(all=True) subgroups = group.subgroups.list(all=True, order_by="path", sort="asc") if len(subgroups) > 0: print(f"- clean {len(subgroups)} sub groups...") for subgroup in subgroups: Loading tests/test_groups.py +20 −20 Original line number Diff line number Diff line Loading @@ -68,8 +68,8 @@ class TestGroups: 'full_path': 'path/to/group' }) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # get initial group group = butler.client.groups.get(butler.group_path) Loading @@ -90,13 +90,13 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'} ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # get initial group group = butler.client.groups.get(butler.group_path) Loading @@ -117,13 +117,13 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'} ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # get initial group group = butler.client.groups.get(butler.group_path) Loading @@ -147,13 +147,13 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'} ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # get initial group group = butler.client.groups.get(butler.group_path) Loading @@ -177,12 +177,12 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 1000, 'path': 'path/to/group/project1'}, {'id': 1001, 'path': 'path/to/group/project2'}, {'id': 1002, 'path': 'path/to/group/project3'}, ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # Setup empty project mock_empty_project('1000') Loading @@ -208,13 +208,13 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 1000, 'path': 'path/to/group/project1'}, {'id': 1001, 'path': 'path/to/group/project2'}, {'id': 1002, 'path': 'path/to/group/project3'}, {'id': 1003, 'path': 'path/to/group/project4'}, ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # Setup empty project mock_empty_project('1000') Loading Loading @@ -244,7 +244,7 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 1000, 'path': 'path/to/group/project0'}, {'id': 1001, 'path': 'path/to/group/project1'}, {'id': 1002, 'path': 'path/to/group/project2'}, Loading @@ -252,7 +252,7 @@ class TestGroups: {'id': 1004, 'path': 'path/to/group/project4'}, {'id': 1005, 'path': 'path/to/group/project5'}, ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # Setup empty project mock_empty_project('1000', project_access=None, group_access=None) # no access Loading Loading
gitlab_butler/butler.py +2 −2 Original line number Diff line number Diff line Loading @@ -446,7 +446,7 @@ class Butler: print(f"🏢 Group {AnsiColors.BLUE}{group.full_path}{AnsiColors.RESET}...") # 2: clean subprojects subprojects = group.projects.list(all=True) subprojects = group.projects.list(all=True, order_by="path", sort="asc") if len(subprojects) > 0: print(f"- clean {len(subprojects)} sub projects...") for project in subprojects: Loading @@ -470,7 +470,7 @@ class Butler: # 3: clean subgroups if not self.skip_subgroups: subgroups = group.descendant_groups.list(all=True) subgroups = group.subgroups.list(all=True, order_by="path", sort="asc") if len(subgroups) > 0: print(f"- clean {len(subgroups)} sub groups...") for subgroup in subgroups: Loading
tests/test_groups.py +20 −20 Original line number Diff line number Diff line Loading @@ -68,8 +68,8 @@ class TestGroups: 'full_path': 'path/to/group' }) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # get initial group group = butler.client.groups.get(butler.group_path) Loading @@ -90,13 +90,13 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'} ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # get initial group group = butler.client.groups.get(butler.group_path) Loading @@ -117,13 +117,13 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'} ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # get initial group group = butler.client.groups.get(butler.group_path) Loading @@ -147,13 +147,13 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'} ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/projects?per_page=100&order_by=path&sort=asc', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # get initial group group = butler.client.groups.get(butler.group_path) Loading @@ -177,12 +177,12 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 1000, 'path': 'path/to/group/project1'}, {'id': 1001, 'path': 'path/to/group/project2'}, {'id': 1002, 'path': 'path/to/group/project3'}, ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # Setup empty project mock_empty_project('1000') Loading @@ -208,13 +208,13 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 1000, 'path': 'path/to/group/project1'}, {'id': 1001, 'path': 'path/to/group/project2'}, {'id': 1002, 'path': 'path/to/group/project3'}, {'id': 1003, 'path': 'path/to/group/project4'}, ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # Setup empty project mock_empty_project('1000') Loading Loading @@ -244,7 +244,7 @@ class TestGroups: responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/43', status=200, json={'id': 43, 'name': 'Sub Group 1', 'full_path': 'path/to/group/sub1'}) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100', status=200, json=[ responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/projects?per_page=100&order_by=path&sort=asc', status=200, json=[ {'id': 1000, 'path': 'path/to/group/project0'}, {'id': 1001, 'path': 'path/to/group/project1'}, {'id': 1002, 'path': 'path/to/group/project2'}, Loading @@ -252,7 +252,7 @@ class TestGroups: {'id': 1004, 'path': 'path/to/group/project4'}, {'id': 1005, 'path': 'path/to/group/project5'}, ]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/descendant_groups?per_page=100', status=200, json=[]) responses.add(responses.GET, 'http://gitlab.test/api/v4/groups/42/subgroups?per_page=100&order_by=path&sort=asc', status=200, json=[]) # Setup empty project mock_empty_project('1000', project_access=None, group_access=None) # no access Loading