diff --git a/galaxy/integrations/gitlab/.rely/mappings.yaml b/galaxy/integrations/gitlab/.rely/mappings.yaml index a35c32d..8ee39b5 100644 --- a/galaxy/integrations/gitlab/.rely/mappings.yaml +++ b/galaxy/integrations/gitlab/.rely/mappings.yaml @@ -26,9 +26,9 @@ resources: openMergeRequestsCount: .openMergeRequestsCount languages: '[.languages[].name]' starCount: .starCount - defaultBranch: '.repository.rootRef // "main"' + defaultBranch: .repository.rootRef updatedAt: .updatedAt - readmeUrl: 'if .repository.blobs.nodes | length > 0 then .webUrl + "/-/blob/" + (.repository.rootRef // "main") + "/" + .repository.blobs.nodes[0].path else "" end' + readmeUrl: 'if .repository.blobs.nodes | length > 0 then .webUrl + "/-/blob/" + .repository.rootRef + "/" + .repository.blobs.nodes[0].path else "" end' readme: 'if .repository.blobs.nodes | length > 0 then .repository.blobs.nodes[0].rawBlob else "" end' defaultBranchRequiredReviews: .requiredReviews["default"] allBranchesRequiredReviews: .requiredReviews["All branches"] diff --git a/galaxy/integrations/gitlab/client.py b/galaxy/integrations/gitlab/client.py index 10de021..8be9944 100644 --- a/galaxy/integrations/gitlab/client.py +++ b/galaxy/integrations/gitlab/client.py @@ -315,6 +315,9 @@ async def get_file(self, repository_path: str, file_path: str) -> dict: async def get_commits( self, project_id: str | int, branch: str, *, exclude_merge_commits: bool = True ) -> list[dict[str, str | int]]: + if not branch: + return [] + all_commits = [] url = f"{self.config.integration.properties['url']}/v4/projects/{project_id}/repository/commits" diff --git a/galaxy/integrations/gitlab/main.py b/galaxy/integrations/gitlab/main.py index 9d8f823..3028a34 100644 --- a/galaxy/integrations/gitlab/main.py +++ b/galaxy/integrations/gitlab/main.py @@ -17,6 +17,8 @@ __all__ = ["Gitlab"] +DEFAULT_BRANCH_NAME: str = "main" + class Gitlab(Integration): _methods = [] @@ -91,8 +93,15 @@ async def groups(self) -> list[dict]: async def repositories(self) -> list[dict]: repos_mapped = [] for group_id, repositories in self.group_to_repos.items(): - self.repositories.update({repo["id"]: repo for repo in repositories}) for repo in repositories: + self.repositories[repo["id"]] = repo + + if repo.get("repository") is None: + repo["repository"] = {} + + if repo["repository"].get("rootRef") is None: + repo["repository"]["rootRef"] = DEFAULT_BRANCH_NAME + repo["requiredReviews"] = get_required_reviews(repo.get("branchRules", [])) if self.repo_files_to_check: repo["repoFilesChecks"] = await self.get_repo_files(repo["fullPath"]) @@ -294,7 +303,7 @@ async def repository_metrics(self) -> list[dict]: all_metrics = [] for repo in self.repositories.values(): project_id = repo["id"].split("/")[-1] - commits = await self.client.get_commits(project_id, branch=repo["repository"].get("rootRef", "main")) + commits = await self.client.get_commits(project_id, branch=repo["repository"]["rootRef"]) repository_metrics = await self.mapper.process( "repository_metrics", [{"commits": commits}], context={"repository": repo} ) diff --git a/galaxy/integrations/pagerduty/.rely/blueprints.json b/galaxy/integrations/pagerduty/.rely/blueprints.json index a0266f3..39af355 100644 --- a/galaxy/integrations/pagerduty/.rely/blueprints.json +++ b/galaxy/integrations/pagerduty/.rely/blueprints.json @@ -248,10 +248,9 @@ "title": "Incident Status", "description": "The status of the PagerDuty incident", "enum": [ - "Active", - "Acknowledged", - "Resolved", - "Open" + "triggered", + "acknowledged", + "resolved" ] }, "assignedVia": {