From df655e76f3c81a3d7e66240d9e7e92de46cc5e29 Mon Sep 17 00:00:00 2001 From: talru1123 <158477883+talru1123@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:21:53 +0200 Subject: [PATCH] [Integrations][Gitlab] Listen to default branch of repository by default (#461) --- integrations/gitlab/CHANGELOG.md | 8 ++++++++ .../gitlab/gitlab_integration/events/hooks/push.py | 6 ++++-- integrations/gitlab/gitlab_integration/git_integration.py | 2 +- integrations/gitlab/pyproject.toml | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/integrations/gitlab/CHANGELOG.md b/integrations/gitlab/CHANGELOG.md index 995f6daea3..8c11a256a1 100644 --- a/integrations/gitlab/CHANGELOG.md +++ b/integrations/gitlab/CHANGELOG.md @@ -7,6 +7,14 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm +0.1.60 (2024-03-25) +=================== + +### Features + +- Changed listening to default branch unless mentioned otherwise in mapping (PORT-7141) + + 0.1.59 (2024-03-24) =================== diff --git a/integrations/gitlab/gitlab_integration/events/hooks/push.py b/integrations/gitlab/gitlab_integration/events/hooks/push.py index c384bda0a1..55793c79f3 100644 --- a/integrations/gitlab/gitlab_integration/events/hooks/push.py +++ b/integrations/gitlab/gitlab_integration/events/hooks/push.py @@ -29,13 +29,15 @@ async def _on_hook(self, body: dict[str, Any], gitlab_project: Project) -> None: GitlabPortAppConfig, event.port_app_config ) - if generate_ref(config.branch) == ref: + branch = config.branch or gitlab_project.default_branch + + if generate_ref(branch) == ref: entities_before, entities_after = self.gitlab_service.get_entities_diff( gitlab_project, config.spec_path, before, after, - config.branch, + branch, ) # update the entities diff found in the `config.spec_path` file the user configured await ocean.update_diff( diff --git a/integrations/gitlab/gitlab_integration/git_integration.py b/integrations/gitlab/gitlab_integration/git_integration.py index 8fa8f4621a..4179db2520 100644 --- a/integrations/gitlab/gitlab_integration/git_integration.py +++ b/integrations/gitlab/gitlab_integration/git_integration.py @@ -126,7 +126,7 @@ class GitlabResourceConfig(ResourceConfig): class GitlabPortAppConfig(PortAppConfig): spec_path: str | List[str] = Field(alias="specPath", default="**/port.yml") - branch: str = "main" + branch: str | None filter_owned_projects: bool | None = Field( alias="filterOwnedProjects", default=True ) diff --git a/integrations/gitlab/pyproject.toml b/integrations/gitlab/pyproject.toml index d0183bf411..84f7f69c74 100644 --- a/integrations/gitlab/pyproject.toml +++ b/integrations/gitlab/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gitlab" -version = "0.1.59" +version = "0.1.60" description = "Gitlab integration for Port using Port-Ocean Framework" authors = ["Yair Siman-Tov "]