@@ -94,19 +94,23 @@ def reset_gitlab(gl: gitlab.Gitlab) -> None:
9494 helpers .safe_delete (deploy_token )
9595 logging .info (f"Deleting project: { project .path_with_namespace !r} " )
9696 helpers .safe_delete (project )
97-
97+
9898 full_paths = [group .full_path for group in gl .groups .list ()]
9999 logging .info (f"Groups to be deleted: { full_paths } " )
100100 for group in gl .groups .list ():
101101 logging .info (f"Current group: { group .full_path !r} , group_id: { group .get_id ()} " )
102- for deploy_token in group .deploytokens .list ():
103- logging .info (
104- f"Deleting deploy token: { deploy_token .username !r} in "
105- f"group: { group .path_with_namespace !r} "
106- )
107- helpers .safe_delete (deploy_token )
108- logging .info (f"Deleting group: { group .full_path !r} " )
109- helpers .safe_delete (group )
102+ descendant_full_paths = [group .full_path for group in group .descendant_groups .list (order_by = "id" , sort = "desc" )]
103+ logging .info (f"Descendant groups to be deleted: { descendant_full_paths } " )
104+ for descendant_group in group .descendant_groups .list (order_by = "id" , sort = "desc" ):
105+ logging .info (f"Current group: { descendant_group .full_path !r} , group_id: { descendant_group .get_id ()} " )
106+ for deploy_token in group .deploytokens .list ():
107+ logging .info (
108+ f"Deleting deploy token: { deploy_token .username !r} in "
109+ f"group: { group .path_with_namespace !r} "
110+ )
111+ helpers .safe_delete (deploy_token )
112+ logging .info (f"Deleting group: { group .full_path !r} " )
113+ helpers .safe_delete (group )
110114 for topic in gl .topics .list ():
111115 logging .info (f"Deleting topic: { topic .name !r} " )
112116 helpers .safe_delete (topic )
0 commit comments