diff --git a/galaxy/integrations/gitlab/.rely/mappings.yaml b/galaxy/integrations/gitlab/.rely/mappings.yaml index 8ee39b5..1c7885f 100644 --- a/galaxy/integrations/gitlab/.rely/mappings.yaml +++ b/galaxy/integrations/gitlab/.rely/mappings.yaml @@ -218,7 +218,7 @@ resources: repository: value: '"gitlab_repo_" + (.context.repository.id | split("/") | last)' triggeredBy: - value: '"gitlab_user_" + (.node.triggerer.id | split("/") | last)' + value: 'if .node.triggerer.id? then "gitlab_user_" + (.node.triggerer.id | split("/") | last) else null end' pipeline: value: '"gitlab_pipeline_" + (.node.job.pipeline.id | split("/") | last)' environment: diff --git a/galaxy/integrations/gitlab/main.py b/galaxy/integrations/gitlab/main.py index 72cff33..e2f8f27 100644 --- a/galaxy/integrations/gitlab/main.py +++ b/galaxy/integrations/gitlab/main.py @@ -1,5 +1,6 @@ import re from types import TracebackType +from enum import Enum from galaxy.core.galaxy import Integration, register from galaxy.core.models import Config @@ -20,6 +21,12 @@ DEFAULT_BRANCH_NAME: str = "main" +class FileCheckStatus(Enum): + FILE_FOUND = "FILE_FOUND" + FILE_NOT_FOUND = "FILE_NOT_FOUND" + FILE_FOUND_NO_MATCH = "FILE_FOUND_NO_MATCH" + + class Gitlab(Integration): _methods = [] # Default Group for previous members of the organization @@ -117,10 +124,15 @@ async def get_repo_files(self, repo_full_path: str) -> dict: for file_check in self.repo_files_to_check: file = await self.client.get_file(repo_full_path, file_check["path"]) if file: - result = re.search(file_check["regex"], file["content"]) if file_check["regex"] else None - repo_file_checks[file_check["destination"]] = result + if file_check["regex"]: + result = re.search(file_check["regex"], file["content"]) if file_check["regex"] else None + repo_file_checks[file_check["destination"]] = ( + result.group(1) if result else FileCheckStatus.FILE_FOUND_NO_MATCH + ) + else: + repo_file_checks[file_check["destination"]] = FileCheckStatus.FILE_FOUND else: - repo_file_checks[file_check["destination"]] = False + repo_file_checks[file_check["destination"]] = FileCheckStatus.FILE_NOT_FOUND return repo_file_checks