From 126538ad7710f421e48210cdff0bc42e0c2b332c Mon Sep 17 00:00:00 2001 From: Matan <51418643+matan84@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:58:16 +0300 Subject: [PATCH] Fixed case where defaultBranch isn't available (#549) # Description What - Fixed case where ADO integration would fail if default branch isn't provided Why - This is failing the integration from fetching repository policies How - Add the key if exists in the repository data, ignore it if not ## Type of change Please leave one option from the following and delete the rest: - [ ] Bug fix (non-breaking change which fixes an issue) --------- Co-authored-by: Yair Siman Tov <63305203+yairsimantov20@users.noreply.github.com> --- integrations/azure-devops/CHANGELOG.md | 6 ++++++ .../azure-devops/azure_devops/client/azure_devops_client.py | 4 +++- integrations/azure-devops/pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/integrations/azure-devops/CHANGELOG.md b/integrations/azure-devops/CHANGELOG.md index 2a50feae64..cb1608669f 100644 --- a/integrations/azure-devops/CHANGELOG.md +++ b/integrations/azure-devops/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +# Port_Ocean 0.1.11 (2024-04-15) + +### Bug Fixes + +- Made defaultBranch not required in the repository body when fetching repository policies + # Port_Ocean 0.1.10 (2024-04-11) ### Improvements diff --git a/integrations/azure-devops/azure_devops/client/azure_devops_client.py b/integrations/azure-devops/azure_devops/client/azure_devops_client.py index 1881ebd2bf..17bc7db536 100644 --- a/integrations/azure-devops/azure_devops/client/azure_devops_client.py +++ b/integrations/azure-devops/azure_devops/client/azure_devops_client.py @@ -102,8 +102,10 @@ async def generate_repository_policies( for repo in repos: params = { "repositoryId": repo["id"], - "refName": repo["defaultBranch"], } + if default_branch := repo.get("defaultBranch"): + params["refName"] = default_branch + policies_url = f"{self._organization_base_url}/{repo['project']['id']}/{API_URL_PREFIX}/git/policy/configurations" repo_policies = ( await self.send_request("GET", policies_url, params=params) diff --git a/integrations/azure-devops/pyproject.toml b/integrations/azure-devops/pyproject.toml index f61b562254..45ee348ef5 100644 --- a/integrations/azure-devops/pyproject.toml +++ b/integrations/azure-devops/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "azure-devops" -version = "0.1.10" +version = "0.1.11" description = "An Azure Devops Ocean integration" authors = ["Matan Geva "]