Commit 11c931f8 authored by Adrian DC's avatar Adrian DC
Browse files

fix(entrypoint, gitlab): implement description to name fallbacks

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 98a6e755
Loading
Loading
Loading
Loading
Loading
+15 −3
Changes for src/cli/entrypoint.py: 15 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -125,8 +125,10 @@ class Entrypoint:

        # Get parent description
        parent_description: str = ''
        parent_name: str = ''
        if parent_group:
            parent_description = parent_group.description
            parent_name = parent_group.name

        # Show group details
        group_type = 'subgroup' if subgroup else 'group'
@@ -144,8 +146,14 @@ class Entrypoint:

        # Update group description
        elif options.update_description:
            parent_description_text: str = ''
            if parent_name:
                parent_description_text = ' - ' + GitLabFeature.Helper.describe(
                    parent_description,
                    parent_name,
                )
            description = f'{GitLabFeature.Helper.capitalize(group.name)}' \
                          f' - {parent_description}'
                          f'{parent_description_text}'
            gitlab.group_set_description(criteria, description)
            print(f'{Colors.BOLD}   - Updated description: '
                  f'{Colors.CYAN}{description}'
@@ -198,11 +206,15 @@ class Entrypoint:

        # Update project description
        elif options.update_description:
            group_description = GitLabFeature.Helper.describe(
                group.description,
                group.name,
            )
            description = f'{GitLabFeature.Helper.capitalize(project.name)}' \
                            f' - {group.description}'
                          f' - {group_description}'
            gitlab.project_set_description(criteria, description)
            print(f'{Colors.BOLD}   - Updated description: '
                  f'{Colors.CYAN}{description}'
                  f'{Colors.CYAN}{group_description}'
                  f'{Colors.RESET}')

        # Reset project features
+10 −0
Changes for src/features/gitlab.py: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -325,3 +325,13 @@ class GitLabFeature:
        @staticmethod
        def capitalize(text: str) -> str:
            return f'{text[:1].capitalize()}{text[1:]}'

        # Describe
        @staticmethod
        def describe(
            description: str,
            name: str,
        ) -> str:
            if description:
                return description
            return GitLabFeature.Helper.capitalize(name)