Commit d07b1799 authored by Adrian DC's avatar Adrian DC
Browse files

feat(cli, gitlab): implement '--prune-unreachable-objects' feature

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 1bf9b99b
Loading
Loading
Loading
Loading
Loading
+5 −3
Changes for README.md: 5 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -55,8 +55,9 @@ usage: gitlab-projects-settings [-h] [--version] [--update-check] [--settings] [
                                [--exclude-projects] [--available-features] [--reset-features [KEEP_FEATURES]]
                                [--disable-features FEATURES] [--enable-features FEATURES] [--reset-members]
                                [--set-avatar FILE] [--set-description TEXT] [--update-description]
                                [--run-housekeeping] [--archive-project | --unarchive-project] [--delete-group]
                                [--delete-project] [--protect-branches] [--protect-tags [LEVEL]] [--]
                                [--run-housekeeping] [--prune-unreachable-objects]
                                [--archive-project | --unarchive-project] [--delete-group] [--delete-project]
                                [--protect-branches] [--protect-tags [LEVEL]] [--]
                                [url_path]

gitlab-projects-settings: Configure GitLab groups and projects settings automatically
@@ -92,7 +93,8 @@ general settings arguments:
  --update-description              # Update description of GitLab projects and groups automatically

advanced settings arguments:
  --run-housekeeping                # Run housekeeping of project or projects GitLab in groups
  --run-housekeeping                # Run housekeeping of GitLab project or projects in groups
  --prune-unreachable-objects       # Prune unreachable objects of GitLab project or projects in groups
  --archive-project                 # Archive project or projects in GitLab groups
  --unarchive-project               # Unarchive project or projects in GitLab groups
  --delete-group                    # Delete group or groups in GitLab groups
+8 −0
Changes for src/cli/entrypoint.py: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -484,6 +484,14 @@ class Entrypoint:
                  f'{Colors.RESET}')
            Platform.flush()

        # Prune project unreachable objects
        if options.prune_unreachable_objects:
            gitlab.project_prune_unreachable_objects(criteria)
            print(f'{Colors.BOLD}   - Pruned unreachable objects: '
                  f'{Colors.GREEN}Success'
                  f'{Colors.RESET}')
            Platform.flush()

        # Archive project
        if options.archive_project:
            gitlab.project_set_archive(criteria, True)
+7 −1
Changes for src/cli/main.py: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -188,7 +188,13 @@ def main() -> None:
        '--run-housekeeping',
        dest='run_housekeeping',
        action='store_true',
        help='Run housekeeping of project or projects GitLab in groups',
        help='Run housekeeping of GitLab project or projects in groups',
    )
    group.add_argument(
        '--prune-unreachable-objects',
        dest='prune_unreachable_objects',
        action='store_true',
        help='Prune unreachable objects of GitLab project or projects in groups',
    )
    subgroup = group.add_mutually_exclusive_group()
    subgroup.add_argument(
+8 −0
Changes for src/features/gitlab.py: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -404,6 +404,14 @@ class GitLabFeature:
        result.sort()
        return result

    # Project prune unreachable objects
    def project_prune_unreachable_objects(self, criteria: str) -> None:

        # Prune project unreachable objects
        if not self.__dry_run:
            project = self.project(criteria)
            project.housekeeping(post_data={'task': 'prune'})

    # Project reset members
    def project_reset_members(self, criteria: str) -> None: