Commit 90102fd2 authored by Mathieu Coupé's avatar Mathieu Coupé Committed by Pierre Smeyers
Browse files

fix: enhance logging

- show number of deleted pipeline per project
- do not display "clean X sub groups" and "clean X sub projects" only if there is some
parent 20f81d81
Loading
Loading
Loading
Loading
+33 −17
Original line number Diff line number Diff line
@@ -387,6 +387,7 @@ class Butler:

        # 2: clean subprojects
        subprojects = group.projects.list(all=True)
        if len(subprojects) > 0:
            print(f"- clean {len(subprojects)} sub projects...")
            for project in subprojects:
                manageable_project = self.client.projects.get(project.id)
@@ -395,11 +396,26 @@ class Butler:
                        f"  - 🏠 Project {AnsiColors.BLUE}{manageable_project.path_with_namespace}{AnsiColors.RESET} matches excludes: {AnsiColors.HGRAY}skip{AnsiColors.RESET}"
                    )
                else:
                    # store current count of cleaned pipeline
                    current_pipeline_count = self.pipelines_count
                    start_time = time.monotonic()

                    # clean project
                    self.clean_project(manageable_project)

                    # show number of pipelines deleted on this project if any
                    if self.pipelines_count > current_pipeline_count:
                        hours, remainder = divmod(time.monotonic() - start_time, 3600)
                        minutes, seconds = divmod(remainder, 60)

                        print(
                            f"    - {self.pipelines_count - current_pipeline_count} pipelines deleted in {int(hours)} hours, {int(minutes)} minutes, {int(seconds)} seconds"
                        )

        # 3: clean subgroups
        if not self.skip_subgroups:
            subgroups = group.descendant_groups.list(all=True)
            if len(subgroups) > 0:
                print(f"- clean {len(subgroups)} sub groups...")
                for subgroup in subgroups:
                    if self.is_excluded(subgroup.full_path):
+114 −125

File changed.

Preview size limit exceeded, changes collapsed.