Verified Commit 7daa0039 authored by Adrian DC's avatar Adrian DC
Browse files

fix(gitlab): resolve faulty error logs in nested 'include:' nodes

Issue: #283
---

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent f1900eb5
Loading
Loading
Loading
Loading
Loading
+13 −8
Changes for src/parsers/gitlab.py: 13 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -305,6 +305,7 @@ class GitLab:
        stack: List[str],
        root_directory: Path,
        working_directory: Path,
        parent_path: str,
    ) -> None:

        # Parse nested include
@@ -337,6 +338,7 @@ class GitLab:
                        root_directory,
                        working_directory,
                        include_dict,
                        parent_path,
                    )

                # Parse project node
@@ -346,9 +348,10 @@ class GitLab:
                        stack,
                        working_directory,
                        include_dict,
                        parent_path,
                    )

    # Include local, pylint: disable=too-many-arguments,too-many-locals
    # Include local, pylint: disable=too-many-arguments,too-many-locals,too-many-positional-arguments
    @staticmethod
    def __include_local(
        data: YAML.Data,
@@ -356,10 +359,10 @@ class GitLab:
        root_directory: Path,
        working_directory: Path,
        include_dict: dict, # type: ignore[type-arg]
        parent_path: str,
    ) -> None:

        # Variables
        include_parent: str = stack[-1] if stack else ''
        include_path: str = include_dict['local']

        # Handle include relative paths
@@ -394,6 +397,7 @@ class GitLab:
                            stack,
                            root_directory,
                            file_path.parent,
                            resolved_path,
                        )

                        # Agregate data
@@ -404,12 +408,12 @@ class GitLab:
                    # Empty included file
                    else:
                        raise SyntaxError(
                            f'Empty "{file_path}" file included in "{include_parent}"')
                            f'Empty "{file_path}" file included in "{parent_path}"')

            # Missing file failure
            else:
                raise FileNotFoundError(
                    f'Missing "{file_path}" file included in "{include_parent}"')
                    f'Missing "{file_path}" file included in "{parent_path}"')

    # Include project
    @staticmethod
@@ -418,10 +422,10 @@ class GitLab:
        stack: List[str],
        working_directory: Path,
        include_dict: dict, # type: ignore[type-arg]
        parent_path: str,
    ) -> None:

        # Variables
        include_parent: str = stack[-1] if stack else ''
        project_path: str = ''
        project_url: str = include_dict['project']

@@ -477,6 +481,7 @@ class GitLab:
                                stack,
                                project_working_directory,
                                project_working_directory,
                                str(file_path),
                            )

                            # Agregate data
@@ -487,13 +492,12 @@ class GitLab:
                        # Empty included file
                        else:
                            raise SyntaxError(
                                f'Empty "{file_path}" file included in "{include_parent}"'
                            )
                                f'Empty "{file_path}" file included in "{parent_path}"')

                # Missing file failure
                else:
                    raise FileNotFoundError(
                        f'Missing "{file_path}" file included in "{include_parent}"')
                        f'Missing "{file_path}" file included in "{parent_path}"')

    # Local, pylint: disable=too-many-branches,too-many-statements
    @staticmethod
@@ -1011,6 +1015,7 @@ class GitLab:
            [Paths.resolve(self.__options.path / self.__options.configuration)],
            self.__options.path,
            self.__options.path,
            Paths.resolve(self.__options.path / self.__options.configuration),
        )

        # Resolve YAML nodes