diff --git a/github_connector/__manifest__.py b/github_connector/__manifest__.py
index 05824dd3..79616e67 100644
--- a/github_connector/__manifest__.py
+++ b/github_connector/__manifest__.py
@@ -6,7 +6,7 @@
{
"name": "Github Connector",
"summary": "Synchronize information from Github repositories",
- "version": "14.0.2.1.0",
+ "version": "14.0.2.2.0",
"category": "Connector",
"license": "AGPL-3",
"author": "Odoo Community Association (OCA), GRAP, Akretion, Tecnativa",
diff --git a/github_connector/migrations/14.0.2.2.0/post-migration.py b/github_connector/migrations/14.0.2.2.0/post-migration.py
new file mode 100644
index 00000000..0e1ef242
--- /dev/null
+++ b/github_connector/migrations/14.0.2.2.0/post-migration.py
@@ -0,0 +1,20 @@
+# Copyright 2023 Simone Rubino - Aion Tech
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+
+from openupgradelib import openupgrade
+
+
+@openupgrade.migrate()
+def migrate(env, version):
+ branches = env["github.repository.branch"].search([])
+ repositories = branches.repository_id
+ repositories.modified(
+ [
+ "complete_name",
+ ]
+ )
+ branches.recompute(
+ fnames=[
+ "complete_name",
+ ],
+ )
diff --git a/github_connector/models/github_repository.py b/github_connector/models/github_repository.py
index 87d8ab1a..3e6487a9 100644
--- a/github_connector/models/github_repository.py
+++ b/github_connector/models/github_repository.py
@@ -15,6 +15,7 @@ class GithubRepository(models.Model):
_inherit = ["abstract.github.model"]
_order = "organization_id, name"
_description = "Github Repository"
+ _rec_name = "complete_name"
_github_login_field = "full_name"
diff --git a/github_connector/models/github_repository_branch.py b/github_connector/models/github_repository_branch.py
index 32857e73..1722bc7a 100644
--- a/github_connector/models/github_repository_branch.py
+++ b/github_connector/models/github_repository_branch.py
@@ -26,6 +26,7 @@ class GithubRepository(models.Model):
_inherit = ["abstract.github.model"]
_order = "repository_id, sequence_serie"
_description = "Github Repository Branch"
+ _rec_name = "complete_name"
_github_login_field = False
@@ -147,6 +148,12 @@ def cron_analyze_all(self):
branches._analyze_code()
return True
+ def find_related_github_object(self, obj_id=None):
+ self.ensure_one()
+ gh_repo = self.repository_id.find_related_github_object()
+ gh_branch = gh_repo.get_branch(self.name)
+ return gh_branch
+
# Custom
def create_or_update_from_name(self, repository_id, name):
branch = self.search(
@@ -344,10 +351,12 @@ def _operation_analysis_rule_id(self, analysis_rule_id):
return res
# Compute Section
- @api.depends("name", "repository_id.name")
+ @api.depends("name", "repository_id.complete_name")
def _compute_complete_name(self):
for branch in self:
- branch.complete_name = branch.repository_id.name + "/" + branch.name
+ branch.complete_name = (
+ branch.repository_id.complete_name + "/" + branch.name
+ )
@api.depends("size")
def _compute_mb_size(self):
@@ -373,7 +382,8 @@ def _compute_local_path(self):
)
for branch in self:
branch.local_path = os.path.join(
- source_path, branch.organization_id.github_name, branch.complete_name
+ source_path,
+ branch.complete_name,
)
@api.depends(
diff --git a/github_connector/readme/CONTRIBUTORS.rst b/github_connector/readme/CONTRIBUTORS.rst
index fa614fc6..ffbe72c1 100644
--- a/github_connector/readme/CONTRIBUTORS.rst
+++ b/github_connector/readme/CONTRIBUTORS.rst
@@ -11,3 +11,6 @@
* Carlos Roca
* Víctor Martínez
* João Marques
+* `Aion Tech `_:
+
+ * Simone Rubino
diff --git a/github_connector/tests/__init__.py b/github_connector/tests/__init__.py
index d62e4b0b..547b2086 100644
--- a/github_connector/tests/__init__.py
+++ b/github_connector/tests/__init__.py
@@ -1,4 +1,7 @@
# Copyright 2021-2022 Tecnativa - Víctor Martínez
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
+
+from . import test_branch
from . import test_github_connector
from . import test_github_analysis_rule
+from . import test_repository
diff --git a/github_connector/tests/test_branch.py b/github_connector/tests/test_branch.py
new file mode 100644
index 00000000..872fdd6f
--- /dev/null
+++ b/github_connector/tests/test_branch.py
@@ -0,0 +1,21 @@
+# Copyright 2023 Simone Rubino - Aion Tech
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+
+from .common import TestGithubConnectorCommon
+
+
+class TestBranch(TestGithubConnectorCommon):
+ def test_display_name(self):
+ """The display name shows
+ the Organization name,
+ the Repository name
+ and the Branch name.
+ """
+ branch = self.repository_ocb_13
+ repository = branch.repository_id
+ organization = repository.organization_id
+
+ display_name = branch.display_name
+ self.assertIn(branch.name, display_name)
+ self.assertIn(repository.name, display_name)
+ self.assertIn(organization.github_name, display_name)
diff --git a/github_connector/tests/test_repository.py b/github_connector/tests/test_repository.py
new file mode 100644
index 00000000..dee26721
--- /dev/null
+++ b/github_connector/tests/test_repository.py
@@ -0,0 +1,18 @@
+# Copyright 2023 Simone Rubino - Aion Tech
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+
+from .common import TestGithubConnectorCommon
+
+
+class TestRepository(TestGithubConnectorCommon):
+ def test_display_name(self):
+ """The display name shows
+ the Organization name
+ and the Repository name.
+ """
+ repository = self.repository_ocb
+ organization = repository.organization_id
+
+ display_name = repository.display_name
+ self.assertIn(repository.name, display_name)
+ self.assertIn(organization.github_name, display_name)